Todoist Sync API OAuth 2.0 support for the PHP League's OAuth 2.0 Client.
You can install the package via composer:
composer require simonkub/oauth2-todoist
// configure and create client
$client = new Simonkub\OAuth2\Client\Todoist([
"clientId" => "CLIENT_ID",
"clientSecret" => "CLIENT_SECRET",
"redirectUri" => "REDIRECT_URI"
]);
// optionally set client scopes, defaults to "data:read"
$client->setDefaultScopes(["data:read"]);
// redirect to todoist login page
$loginPageUri = $client->getAuthorizationUrl();
// after login and beeing redirected back to your application
// read authorization code from request
$authorizationCode = $_GET['code'];
// exchange authorization code for token
$token = $client->getAccessToken("authorization_code", [
"code" => $authorizationCode
]);
// read single resource
$response = $client->readResource("projects", $token);
// read multiple resources
$response = $client->readResources(["projects", "labels"], $token);
// write resource
$commands = [
"type" => "item_add",
"uuid" => uniqid(),
"temp_id" => uniqid(),
"args" => [
"project_id" => "foo",
"content" => "bar"
]
];
$response = $client->writeResources($commands, $token);
composer test
Please see CHANGELOG for more information on what has changed recently.
Please see CONTRIBUTING for details.
Please review our security policy on how to report security vulnerabilities.
The MIT License (MIT). Please see License File for more information.