\OCLC\AuthAccessToken

A class that represents a client's OCLC Access Token.

An Access Token typically represents the rights of an application

  • to access specific web services
  • to interact with data at a specific insitution
  • on behalf of a specific a given user Access Tokens have several properties including
  • Token String
  • Token Type
  • Expires
  • Expires At They also may have a Refresh Token Object with three properties
  • Refresh Token (string value)
  • Refresh Token Expires In
  • Refresh Token Expires At

Summary

Methods
Properties
Constants
getAccessTokenUrl()
getContextInstitutionID()
getResponse()
getType()
getValue()
getExpiresIn()
getExpiresAt()
getUser()
getRefreshToken()
isExpired()
__construct()
create()
refresh()
$authorizationServer
$testServer
$userAgent
$validOptions
$validGrantTypes
No constants found
No protected methods found
No protected properties found
N/A
requestAccessToken()
buildAccessTokenURL()
parseTokenResponse()
$grant_type
$authenticatingInstitutionId
$contextInstitutionId
$redirectUri
$scope
$logger
$logFormat
$testMode
$headers
$accessTokenUrl
$wskey
$user
$response
$type
$accessTokenString
$expiresIn
$expiresAt
$refreshToken
N/A

Properties

$authorizationServer

$authorizationServer : array

The url for the authorization server

Type

array — static $authorizationServer

$testServer

$testServer : \OCLC\Auth\binary

Whether or not to operate in test server mode

Type

\OCLC\Auth\binary — static $testServer

$userAgent

$userAgent : string

The user agent string

Type

string — static $userAgent

$validOptions

$validOptions : array

An array of the valid options which can be passed in

Type

array — static $validOptions

$validGrantTypes

$validGrantTypes : array

An array of the valid grant types

Type

array — static $validGrantTypes

$grant_type

$grant_type : string

The grant type being used

Type

string

$authenticatingInstitutionId

$authenticatingInstitutionId : integer

The authenticating institutionId

Type

integer

$contextInstitutionId

$contextInstitutionId : integer

The content institution id

Type

integer

$redirectUri

$redirectUri : string

The redirect uri

Type

string

$scope

$scope : array

An array of scopes

Type

array

$logger

$logger : \OCLC\Auth\unknown

The logger object

Type

\OCLC\Auth\unknown

$logFormat

$logFormat : string

The format to log in

Type

string

$testMode

$testMode : boolean

Whether or not to run in test mode

Type

boolean

$headers

$headers : array

An array of headers

Type

array

$accessTokenUrl

$accessTokenUrl : string

The url for requesting the Access token

Type

string

$wskey

$wskey : \OCLC\Auth\OCLC\Auth\WSKey

WSKey

Type

\OCLC\Auth\OCLC\Auth\WSKey

$user

$user : \OCLC\Auth\OCLC\User

User

Type

\OCLC\Auth\OCLC\User

$response

$response : string

The JSON response

Type

string

$type

$type : string

The Access token type

Type

string

$accessTokenString

$accessTokenString : string

The access token string value

Type

string

$expiresIn

$expiresIn : integer

How many milliseconds in which the Access token expires

Type

integer

$expiresAt

$expiresAt : string

The time in UTC when the Access Token Expires

Type

string

$refreshToken

$refreshToken : \OCLC\Auth\OCLC\Auth\RefreshToken

The Refresh token associated with the Access Token

Type

\OCLC\Auth\OCLC\Auth\RefreshToken

Methods

getAccessTokenUrl()

getAccessTokenUrl() : string

Get Access Token URL

Returns

string

getContextInstitutionID()

getContextInstitutionID() : integer

Get Context Institution ID

Returns

integer

getResponse()

getResponse() : string

Get JSON Access Token Response

Returns

string

getType()

getType() : string

Get Access Token Type

Returns

string

getValue()

getValue(boolean  $autoRefresh = true) : string

Get Value of Access Token

Parameters

boolean $autoRefresh

Returns

string

getExpiresIn()

getExpiresIn() : integer

Get Access Token Expires In

Returns

integer

getExpiresAt()

getExpiresAt() : string

Get Access Token Expires At

Returns

string

getUser()

getUser() : \OCLC\Auth\OCLC/User

Get User Object

Returns

\OCLC\Auth\OCLC/User

getRefreshToken()

getRefreshToken() : \OCLC\Auth\OCLC/Auth/RefreshToken

get Refresh Token

Returns

\OCLC\Auth\OCLC/Auth/RefreshToken

isExpired()

isExpired() : boolean

Return if the Access Token is Expired on Not

Returns

boolean

__construct()

__construct(string  $grantType, array  $options) 

Construct a new Access Token

Parameters

string $grantType
  • there are three possible values: authorization_code, client_credentials, or refresh_token. Each of these require different options be set in the constructor
    • authorization_code -- code, redirect_uri, scope, authenticatingInstitutionId, contextInstitutionId must be set
    • client_credentials -- scope, authenticatingInstitutionId, contextInstitutionId must be set
    • refresh_token -- refresh_token option must be set
array $options
  • an associative array of options for constructing the Access Token. Possible indexes
    • wskey - \OCLC\Auth\WSKey
    • scope - array of scopes
    • authenticatingInstitutionId
    • contextInstitutionId
    • redirect_uri
    • code
    • refreshToken - refreshToken object
    • accessTokenString
    • expiresAt
    • logger
    • logFormat

create()

create(\OCLC\Auth\OCLC\Auth\WSKey  $wskey, \OCLC\Auth\OCLC\User  $user = null) 

Create a new Access Token

Create a new Access Token by making a request to the Authorization Server. If successful add properties to Access Token Object

Parameters

\OCLC\Auth\OCLC\Auth\WSKey $wskey

A valid WSKey object

\OCLC\Auth\OCLC\User $user

A valid User object

Throws

\OCLC\Auth\Exception

refresh()

refresh() 

Refresh the current Access Token

Throws

\LogicException

requestAccessToken()

requestAccessToken(string  $authorization, string  $url, string  $logger = null,   $log_format = null) 

Make the request for an Access Token

Parameters

string $authorization
string $url
string $logger
$log_format

buildAccessTokenURL()

buildAccessTokenURL() 

Build the URL to retrieve the Access Token

parseTokenResponse()

parseTokenResponse(string  $responseJSON) 

Parse the Access Token Response Parses the Access Token Response received from the Authorization Server and adds the relevant information to the Access Token object as properties

Parameters

string $responseJSON

JSON Response from the Authorization Server