The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

WebService::GoogleAPI::Client::AuthStorage::GapiJSON - Auth Storage Backend based on gapi.json

VERSION

version 0.27

SYNOPSIS

This class provides an auth backend for gapi.json files produced with the provided goauth script. This is used for user credentials. For service accounts, please see WebService::GoogleAPI::Client::AuthStorage::ServiceAccount.

In future versions, I hope to provide the functionality of goauth as a Mojolicious::Plugin, so you can provide this flow in your app rather than having to run it offline.

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

path

The location of the gapi.json file. Default to gapi.json in the current directory.

tokensfile

A Config::JSON object that contains the parsed gapi.json file. Authomatically set at object instantiation.

METHODS

get_access_token

Returns the access token for the current user.

refresh_access_token

This will refresh the access token for the currently set user. Will write the new token back into the gapi.json file.

If you don't have a refresh token for that user, it will die with the following message:

If your credentials are missing the refresh_token - consider removing the auth at https://myaccount.google.com/permissions as The oauth2 server will only ever mint one refresh token at a time, and if you request another access token via the flow it will operate as if you only asked for an access token.

get_from_storage

A method to get stored fields from the gapi.json file. Will retrieve tokens for the current user, and other fields from the global config.

scopes

Read-only accessor returning the list of scopes configured in the gapi.json file.

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