simonkub/oauth2-todoist

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

1.0.0 2020-12-17 16:02 UTC

This package is auto-updated.

Last update: 2024-04-17 23:26:44 UTC


README

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.