NAME
Net::Async::Spotify::Token - Representation for Spotify Token Object
SYNOPSIS
use Net::Async::Spotify::Token;
my $token = Net::Async::Spotify::Token->new(
access_token => "NgCXRK...MzYjw",
token_type => "Bearer",
scope => "user-read-private user-read-email",
expires_in => 3600,
refresh_token => "NgAagA...Um_SHo",
);
my $time_obtained = $token->updated_at->epoch;
my $auth_header = $token->header_string;
# Bearer NgCXRK...MzYjw
my $new_token = {access_token => 'NEW...ONE',}; # can have the reset of params.
$token->renew($new_token);
my $new_time = $token->updated_at->epoch;
DESCRIPTION
Class representing Spotify Token Object. Adds some functionality to Token object where it's easier to deal with. More details about Token itself, RFC-6749.
PARAMETERS
- access_token
-
Spotify App User access_token
- refresh_token
-
Spotify App User refresh_token
- token_type
-
Spotify Token type, usually it's set to `Bearer` when used with Access Token. However it's also set to `Basic` when used with Authentication.
- expires_in
-
Token validity in seconds from obtained time. set in
updated_at
- scope
-
Spotify App User token allowed scope list https://developer.spotify.com/documentation/general/guides/scopes/
METHODS
renew
call this method while passing a new Token hash, to update the current Token Object. Accepts the same hash that you'd pass it in new()
.
access_token
Mutator for Spotify User's Access Token, every time its set updated_at
field will be set to the current time. It will return the current set Spotify Access Token.
updated_at
it will return Time::Moment Object, indicating Spotify Access Token last set time.
refresh_token
set and get, or just get the current Spotify user's Refresh Token
token_type
set and get, or just get the Token type, default is set to `Bearer`
expires_in
set and get, or just get the Token expires_in filed. Default is set to 3600 (seconds)
scope
set and get, or just get the configured Spotify Scopes for the Token. Accepts a space space separated list of Scopes, or an Array reference of Scopes. Returns an Array reference of Spotify Scopes set to Token. https://developer.spotify.com/documentation/general/guides/scopes/
header_string
Returns a String, containing the Token type and the Access Token, space separated. Needed for Authorization header.