NAME
WebService::GoogleAPI::Client::AuthStorage::ServiceAccount - Manage access tokens from a service account file
VERSION
version 0.27
SYNOPSIS
This class provides an auth backend for service account files downloaded from your google cloud console. For user accounts, please see WebService::GoogleAPI::AuthStorage::GapiJSON.
This backend is only for explicitly passing a service account JSON file. It will not attempt to find one by itself, or to do the Application Default Credentials, at least yet.
This backend will cache tokens in memory for any set of scopes requested, and for any user you ask to impersonate (more on that later).
This class mixes in WebService::GoogleAPI::Client::AuthStorage, and provides all attributes and methods from that role. As noted there, the ua
is usually managed by the WebService::GoogleAPI::Client object this is set on.
ATTRIBUTES
scopes
A read/write attribute containing the scopes the service account is asking access to. Will coerce a space seperated list of scopes into the required arrayref of scopes.
user
The user you want to impersonate. Defaults to the empty string, which signifies no user. In order to impersonate a user, you need to have domain-wide delegation set up for the service account.
path
The location of the file containing the service account credentials. This is downloaded from your google cloud console's service account page.
jwt
An instance of Mojo::JWT::Google used for retrieving the access tokens. This is built whenever the path
attribute is set.
tokens
A hash for caching the tokens that have been retrieved by this object. It caches on scopes (via the scopes_string
method) and then user.
METHODS
get_access_token
Return an access token for the current user (if any) and scopes from the cache if exists, otherwise retrieve a new token with refresh_access_token
.
refresh_access_token
Retrieve an access token for the current user (if any) and scopes from Google's auth API, using a JWT.
scopes_string
Return the list of scopes as a space seperated string.
AUTHOR
Veesh Goldman <veesh@cpan.org>
COPYRIGHT AND LICENSE
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