STATE
STATE
Conduct negotiations with Canvas for an OAuth token
__construct(string $OAuthEndpoint, string $clientId, string $clientSecret, string $landingPage = false, string $purpose = null, string $APIEndpoint = false, string $scopes = self::DEFAULT_SCOPE, string $responseType = 'code', $redirectURI = null) : void
Construct OAuthNegotiator to start (or continue) OAuth authentication negotiations
string | $OAuthEndpoint | optional URI of the OAuth authentication endpoint (e.g. 'https:// |
string | $clientId | optional A unique client ID for the application requesting authentication (usually some terrible hash or serial number) -- REQUIRED on first instantiation |
string | $clientSecret | optional A shared secret key between this application and the OAuth server -- REQUIRED on first instantiation |
string | $landingPage | optional URI to land at after OAuth is negotiated (defaults to $_SERVER[PHP_SELF]) |
string | $purpose | optional How this authentication token will be used (defaults to $_SERVER[PHP_SELF]) |
string | $APIEndpoint | optional URI of the API endpoint (e.g. 'https:// |
string | $scopes | optional The scope of this authentication (defaults to API token request) |
string | $responseType | optional Type of response expected from OAuth server (defaults to 'code') |
$redirectURI |
OAUTH_ENDPOINT if $OAuthEndpoint is empty or not provided
CLIENT_ID if $clientId is empty or not provided
CLIENT_SECRET if $clientSecret is empty or not provided
STATE_MISMATCH if $_REQUEST[state] does not align with $_SESSION[SESSION][STATE]
constructStateless(string $OAuthEndpoint, string $clientId, string $clientSecret, string $landingPage = false, string $purpose = null, string $APIEndpoint = false, string $scopes = self::DEFAULT_SCOPE, string $responseType = 'code', $redirectURI = null)
Construct a "stateless" (i.e. unstarted) OAuthNegotiator
string | $OAuthEndpoint | URI of the OAuth authentication endpoint (e.g. 'https:// |
string | $clientId | A unique client ID for the application requesting authentication (usually some terrible hash or serial number) |
string | $clientSecret | A shared secret key between this application and the OAuth server |
string | $landingPage | optional URI to land at after OAuth is negotiated (defaults to $_SERVER[PHP_SELF]) |
string | $purpose | optional How this authentication token will be used (defaults to $_SERVER[PHP_SELF]) |
string | $APIEndpoint | optional URI of the API endpoint (e.g. 'https:// |
string | $scopes | optional The scope of this authentication (defaults to API token request) |
string | $responseType | optional Type of response expected from OAuth server (defaults to 'code') |
$redirectURI |
OAUTH_ENDPOINT if $OAuthEndpoint is empty or not provided
CLIENT_ID if $clientId is empty or not provided
CLIENT_SECRET if $clientSecret is empty or not provided
constructAPIToken() : void
Construct an OAuthNegotiator to use an access code to request an API Token with matching user profile
CODE_RESPONSE if the prior request for an authorization token resulted in neither an authorization code or an error (weird!)
USER_RESPONSE if a user profile cannot be acquired to match the API access token (i.e. the OAuth server is probably not a Canvas instance)
requestAuthorizationCode(string $responseType, string $scopes, string $purpose) : void
Request an authorization code from the OAuth server
string | $responseType | Always 'code' |
string | $scopes | The type of token for which we need an authorization code (IDENTITY_TOKEN|API_TOKEN) |
string | $purpose | User-readable description of the purpose for which this token will be used |
requestToken(string $code, string $tokenType) : void
Request a token from the OAuth server
string | $code | An authorization code provided by the OAuth server |
string | $tokenType | Type of token being requested (IDENTITY_TOKEN|API_TOKEN) |
TOKEN_RESPONSE if a token no token is received or on any other uanticipated response from the OAuth server