GDAL
Public Types | Public Member Functions | List of all members
GOA2Manager Class Reference

Manager of Google OAuth2 authentication. More...

#include <cpl_http.h>

Public Types

enum  AuthMethod { NONE, GCE, ACCESS_TOKEN_FROM_REFRESH, SERVICE_ACCOUNT }
 Authentication method.
 

Public Member Functions

 GOA2Manager ()
 Constructor.
 
bool SetAuthFromGCE (char **papszOptions)
 Specifies that the authentication will be done using the local credentials of the current Google Compute Engine VM. More...
 
bool SetAuthFromRefreshToken (const char *pszRefreshToken, const char *pszClientId, const char *pszClientSecret, char **papszOptions)
 Specifies that the authentication will be done using the OAuth2 client id method. More...
 
bool SetAuthFromServiceAccount (const char *pszPrivateKey, const char *pszClientEmail, const char *pszScope, char **papszAdditionalClaims, char **papszOptions)
 Specifies that the authentication will be done using the OAuth2 service account method. More...
 
AuthMethod GetAuthMethod () const
 Returns the authentication method. More...
 
const char * GetBearer () const
 Return the access token. More...
 

Detailed Description

Manager of Google OAuth2 authentication.

This class handles different authentication methods and handles renewal of access token.

Since
GDAL 2.3

Member Function Documentation

AuthMethod GOA2Manager::GetAuthMethod ( ) const
inline

Returns the authentication method.

const char * GOA2Manager::GetBearer ( ) const

Return the access token.

This is the value to append to a "Authorization: Bearer " HTTP header.

A network request is issued only if no access token has been yet queried, or if its expiration delay has been reached.

Returns
the access token, or NULL in case of error.
bool GOA2Manager::SetAuthFromGCE ( char **  papszOptions)

Specifies that the authentication will be done using the local credentials of the current Google Compute Engine VM.

This queries http://metadata.google.internal/computeMetadata/v1/instance/service-accounts/default/token

Parameters
papszOptionsNULL terminated list of options.
Returns
true in case of success (no network access is done at this stage)
bool GOA2Manager::SetAuthFromRefreshToken ( const char *  pszRefreshToken,
const char *  pszClientId,
const char *  pszClientSecret,
char **  papszOptions 
)

Specifies that the authentication will be done using the OAuth2 client id method.

See http://code.google.com/apis/accounts/docs/OAuth2.html

Parameters
pszRefreshTokenrefresh token. Must be non NULL.
pszClientIdclient id (may be NULL, in which case the GOA2_CLIENT_ID configuration option is used)
pszClientSecretclient secret (may be NULL, in which case the GOA2_CLIENT_SECRET configuration option is used)
papszOptionsNULL terminated list of options, or NULL.
Returns
true in case of success (no network access is done at this stage)
bool GOA2Manager::SetAuthFromServiceAccount ( const char *  pszPrivateKey,
const char *  pszClientEmail,
const char *  pszScope,
char **  papszAdditionalClaims,
char **  papszOptions 
)

Specifies that the authentication will be done using the OAuth2 service account method.

See https://developers.google.com/identity/protocols/OAuth2ServiceAccount

Parameters
pszPrivateKeyRSA private key. Must be non NULL.
pszClientEmailclient email. Must be non NULL.
pszScopeauthorization scope. Must be non NULL.
papszAdditionalClaimsNULL terminate list of additional claims, or NULL.
papszOptionsNULL terminated list of options, or NULL.
Returns
true in case of success (no network access is done at this stage)

The documentation for this class was generated from the following files:

Generated for GDAL by doxygen 1.8.8.