PHP Class AsanaAuth

The use of this class is totally optional and you can use any other oauth implementation if prefered. Copyright 2016 Ajimix Licensed under the Apache License 2.0 Authors: Ajimix [github.com/ajimix], Puchol [https://github.com/puchol] Version: 2.0.0
Show file Open project: ajimix/asana-api-php-class Class Usage Examples

Public Properties

Property Type Description
$responseCode

Public Methods

Method Description
__construct ( string $clientId, string $clientSecret, string $redirectUrl ) Class constructor.
getAccessToken ( string $authCode ) : string Converts an authorization code into an access token via a call to the asana servers.
getAuthorizeUrl ( ) : string Returns the url for the authorization.
getData ( ) : object Decodes the response and returns as an object.
hasError ( ) : boolean Checks for errors in the response.
refreshAccessToken ( string $refreshToken ) : string Ask asana to refresh the token with a new one.

Private Methods

Method Description
askAsana ( string $action, string $token ) : string This function communicates with Asana REST API.

Method Details

__construct() public method

Class constructor.
public __construct ( string $clientId, string $clientSecret, string $redirectUrl )
$clientId string Client ID given by asana app creator.
$clientSecret string Client secret given by asana app creator.
$redirectUrl string Redirect url, must match the one given in asana app creator.

getAccessToken() public method

Converts an authorization code into an access token via a call to the asana servers.
public getAccessToken ( string $authCode ) : string
$authCode string The authorization code provided via asana after the proper authorization.
return string JSON or null.

getAuthorizeUrl() public method

Use this url to redirect the user, let the user authorize your application, and then come back to your application with the token.
public getAuthorizeUrl ( ) : string
return string The authorization url.

getData() public method

Decodes the response and returns as an object.
public getData ( ) : object
return object or null

hasError() public method

Checks for errors in the response.
public hasError ( ) : boolean
return boolean

refreshAccessToken() public method

Ask asana to refresh the token with a new one.
public refreshAccessToken ( string $refreshToken ) : string
$refreshToken string The refresh token provided by asana on getting the access token.
return string JSON or null.

Property Details

$responseCode public property

public $responseCode