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

#include <cpl_http.h>

Public Types

enum  AuthMethod
 

Public Member Functions

 GOA2Manager ()
 
bool SetAuthFromGCE (CSLConstList papszOptions)
 
bool SetAuthFromRefreshToken (const char *pszRefreshToken, const char *pszClientId, const char *pszClientSecret, CSLConstList papszOptions)
 
bool SetAuthFromServiceAccount (const char *pszPrivateKey, const char *pszClientEmail, const char *pszScope, CSLConstList papszAdditionalClaims, CSLConstList papszOptions)
 
AuthMethod GetAuthMethod () const
 
const char * GetBearer () const
 
const CPLStringGetPrivateKey () const
 
const CPLStringGetClientEmail () const
 

Detailed Description

Manager of Google OAuth2 authentication.

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

Since
GDAL 2.3

Member Enumeration Documentation

◆ AuthMethod

Authentication method

Constructor & Destructor Documentation

◆ GOA2Manager()

GOA2Manager::GOA2Manager ( )
default

Constructor

Member Function Documentation

◆ GetAuthMethod()

AuthMethod GOA2Manager::GetAuthMethod ( ) const
inline

Returns the authentication method.

◆ GetBearer()

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.

References CSLDestroy(), CSLFetchNameValue(), GOA2GetAccessTokenFromCloudEngineVM(), GOA2GetAccessTokenFromServiceAccount(), and CPLStringList::List().

◆ GetClientEmail()

const CPLString& GOA2Manager::GetClientEmail ( ) const
inline

Returns client email for SERVICE_ACCOUNT method

◆ GetPrivateKey()

const CPLString& GOA2Manager::GetPrivateKey ( ) const
inline

Returns private key for SERVICE_ACCOUNT method

◆ SetAuthFromGCE()

bool GOA2Manager::SetAuthFromGCE ( CSLConstList  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)

◆ SetAuthFromRefreshToken()

bool GOA2Manager::SetAuthFromRefreshToken ( const char *  pszRefreshToken,
const char *  pszClientId,
const char *  pszClientSecret,
CSLConstList  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)

References CPLError().

◆ SetAuthFromServiceAccount()

bool GOA2Manager::SetAuthFromServiceAccount ( const char *  pszPrivateKey,
const char *  pszClientEmail,
const char *  pszScope,
CSLConstList  papszAdditionalClaims,
CSLConstList  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)

References CPLError(), and EQUAL.


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

Generated for GDAL by doxygen 1.8.14.