2017 © Pedro Peláez
 

library oauth2-todoist

A Todoist.com provider for league/oauth2-client

image

todomove/oauth2-todoist

A Todoist.com provider for league/oauth2-client

  • Thursday, October 27, 2016
  • by ashleyhindle
  • Repository
  • 1 Watchers
  • 1 Stars
  • 743 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

Todoist.com Provider for OAuth 2.0 Client

This package provides TodoistOauth 2.0 support for the PHP League's OAuth 2.0 Client., (*1)

Installation

To install, use composer:, (*2)

composer require todomove/oauth2-todoist

Usage

Usage is the same as The League's OAuth client, using TodoMove\OAuth2\Client\Provider\Todoist as the provider., (*3)

Authorization Code Flow

$provider = new TodoMove\OAuth2\Client\Provider\Todoist([
    'clientId'          => '{client-id}',
    'clientSecret'      => '{client-secret}',
    'redirectUri'       => 'https://example.com/callback-url'
]);

if (!isset($_GET['code'])) {

    // If we don't have an authorization code then get one
    $authUrl = $provider->getAuthorizationUrl();
    $_SESSION['oauth2state'] = $provider->state;
    header('Location: '.$authUrl);
    exit;

// Check given state against previously stored one to mitigate CSRF attack
} elseif (empty($_GET['state']) || ($_GET['state'] !== $_SESSION['oauth2state'])) {

    unset($_SESSION['oauth2state']);
    exit('Invalid state');

} else {

    // Try to get an access token (using the authorization code grant)
    $token = $provider->getAccessToken('authorization_code', [
        'code' => $_GET['code']
    ]);

    // Use this to interact with an API on the users behalf
    echo $token->getToken();
}

The Versions

27/10 2016

dev-master

9999999-dev

A Todoist.com provider for league/oauth2-client

  Sources   Download

MIT

The Requires

 

authorization oauth client oauth2 authorisation todoist

27/10 2016

0.1.0

0.1.0.0

A Todoist.com provider for league/oauth2-client

  Sources   Download

MIT

The Requires

 

authorization oauth client oauth2 authorisation todoist