OauthServiceTrait
Helper trait for OAuth 2.0 connections.
Classes which use this trait should also use LoggerAwareTrait.
Closely adapted from VuFind\DigitalContent\OverdriveConnector.
Tags
Table of Contents
- $tokenData : stdClass
- Current OAuth token
- authenticateWithClientCredentials() : stdClass|bool
- Authenticate via the OAuth Client Credentials grant type.
- oauthServiceTraitDebug() : void
- Log a debug message, if $this->log exists.
- oauthServiceTraitError() : void
- Log an error message, if $this->log exists.
- oauthServiceTraitLog() : void
- Log a message, if $this->log exists.
Properties
$tokenData
Current OAuth token
protected
stdClass
$tokenData
= null
Methods
authenticateWithClientCredentials()
Authenticate via the OAuth Client Credentials grant type.
public
authenticateWithClientCredentials(string $oauthUrl, string $clientId, string $clientSecret) : stdClass|bool
Parameters
- $oauthUrl : string
-
URL of thee OAuth service
- $clientId : string
-
client_id for a client_credentials grant
- $clientSecret : string
-
client_secret for a client_credentials grant
Tags
Return values
stdClass|bool —token for the session or false if the token request failed
oauthServiceTraitDebug()
Log a debug message, if $this->log exists.
protected
oauthServiceTraitDebug(string $msg) : void
Parameters
- $msg : string
-
Log message
Return values
void —oauthServiceTraitError()
Log an error message, if $this->log exists.
protected
oauthServiceTraitError(string $msg) : void
Parameters
- $msg : string
-
Log message
Return values
void —oauthServiceTraitLog()
Log a message, if $this->log exists.
protected
oauthServiceTraitLog(string $level, string $msg) : void
Parameters
- $level : string
-
Logging level
- $msg : string
-
Log message