Skip to content

This package provides Todoist OAuth 2.0 support for the PHP League's OAuth 2.0 Client.

License

Notifications You must be signed in to change notification settings

simonkub/oauth2-todoist

Repository files navigation

Todoist Provider for OAuth 2.0 Client

Latest Version on Packagist Tests Total Downloads

Todoist Sync API OAuth 2.0 support for the PHP League's OAuth 2.0 Client.

Installation

You can install the package via composer:

composer require simonkub/oauth2-todoist

Usage

// 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);

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.

About

This package provides Todoist OAuth 2.0 support for the PHP League's OAuth 2.0 Client.

Resources

License

Security policy

Stars

Watchers

Forks

Packages

No packages published

Languages