WebService::GoogleAPI::Client::AuthStorage - Role for classes which store your auth credentials
version 0.27
package My::Cool::AuthStorage::Class; use Moo; with 'WebService::GoogleAPI::Client::AuthStorage'; ... # implement the necessary functions package main; use WebService::GoogleAPI::Client; use My::Cool::AuthStorage::Class; my $gapi = WebService::GoogleAPI::Client->new( auth_storage => My::Cool::AuthStorage::Class->new ); ... # and now your class manages the access_tokens
WebService::GoogleAPI::Client::AuthStorage is a Moo::Role for auth storage backends. This dist comes with two consumers, WebService::GoogleAPI::Client::AuthStorage::GapiJSON and WebService::GoogleAPI::Client::AuthStorage::ServiceAccount. See those for more info on how you can use them with WebService::GoogleAPI::Client.
This is a role which defines the interface that WebService::GoogleAPI::Client will use when making requests.
The user that an access token should be returned for. Is read/write. May be falsy, depending on the backend.
An weak reference to the WebService::GoogleAPI::Client::UserAgent that this is attached to, so that access tokens can be refreshed. The UserAgent object manages this.
Makes the call to Google's OAuth API to refresh a token for a user. Requires one parameter, a hashref with the keys:
Will return the token from the API, for the backend to store (wherever it pleases).
Will die with the error message from Google if the refresh fails.
Makes the call to Google's OAuth API to refresh a token for a service account. Requires one parameter, a Mojo::JWT::Google object already set with the user and scopes requested.
It requires the consuming class to implement functions with the following names:
A list of scopes that you expect the access token to be valid for. This could be read/write, but it's not necessary. Some backends may have different credentials for different sets of scopes (though as an author, you probably want to just have the whole set you need upfront).
A method which will refresh the access token if it has been determined to have expired. Take a look at the two consumers which come with this dist for examples of how to renew user credentials and service account credentials.
A method which will return the access token for the current user and scopes. This method is wrapped to augment whatever has been returned with user and scopes data for introspection by making a WebService::GoogleAPI::Client::AccessToken instance. If you choose to return such an instance yourself, then it will be left alone.
Veesh Goldman <veesh@cpan.org>
This software is Copyright (c) 2017-2023 by Veesh Goldman and Others.
This is free software, licensed under:
The Apache License, Version 2.0, January 2004
To install WebService::GoogleAPI::Client, copy and paste the appropriate command in to your terminal.
cpanm
cpanm WebService::GoogleAPI::Client
CPAN shell
perl -MCPAN -e shell install WebService::GoogleAPI::Client
For more information on module installation, please visit the detailed CPAN module installation guide.