NAME

OIDC::Client::AccessToken - Access Token class

DESCRIPTION

Class representing an access token

ATTRIBUTES

token

The string of the access token. Required

token_type

The type of the access token

expires_at

The expiration time of the access token (number of seconds since 1970-01-01T00:00:00Z)

scopes

The scopes (arrayref) of the access token

claims

Hashref of claims coming from the access token. Optional, as an access token is not always decoded, depending on the nature of the application.

METHODS

has_scope( $expected_scope )

my $has_scope = $access_token->has_scope($expected_scope);

Returns whether a scope is present in the scopes of the access token.

has_expired( $leeway )

my $has_expired = $access_token->has_expired($leeway);

Returns whether the access token has expired.

Returns undef if the expires_at attribute is not defined.

The list parameters are:

leeway

Number of seconds of leeway for the token to be considered expired before it actually is.

compute_at_hash( $alg )

my $at_hash = $access_token->compute_at_hash($alg);

Returns the computed at_hash for access token. The at_hash is created by hashing the access token using the algorithm specified in the $alg parameter, taking the left-most half of the hash, and then base64url encoding it.

verify_at_hash( $expected_at_hash, $alg )

$access_token->verify_at_hash($expected_at_hash, $alg);

If the value of the $expected_at_hash parameter is undefined, returns a true value. Throws an OIDC::Client::Error::TokenValidation exception if the computed at_hash for access token and specified $alg algorithm does not match the value of the $expected_at_hash parameter. Otherwise, returns a true value.

to_hashref()

my $access_token_href = $access_token->to_hashref();

Returns a hashref of the access token data.