OGR
|
#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 CPLString & | GetPrivateKey () const |
const CPLString & | GetClientEmail () const |
Manager of Google OAuth2 authentication.
This class handles different authentication methods and handles renewal of access token.
Authentication method
|
default |
Constructor
|
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.
References CSLDestroy(), CSLFetchNameValue(), GOA2GetAccessTokenFromCloudEngineVM(), GOA2GetAccessTokenFromServiceAccount(), and CPLStringList::List().
|
inline |
Returns client email for SERVICE_ACCOUNT method
|
inline |
Returns private key for SERVICE_ACCOUNT method
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
papszOptions | NULL terminated list of options. |
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
pszRefreshToken | refresh token. Must be non NULL. |
pszClientId | client id (may be NULL, in which case the GOA2_CLIENT_ID configuration option is used) |
pszClientSecret | client secret (may be NULL, in which case the GOA2_CLIENT_SECRET configuration option is used) |
papszOptions | NULL terminated list of options, or NULL. |
References CPLError().
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
pszPrivateKey | RSA private key. Must be non NULL. |
pszClientEmail | client email. Must be non NULL. |
pszScope | authorization scope. Must be non NULL. |
papszAdditionalClaims | NULL terminate list of additional claims, or NULL. |
papszOptions | NULL terminated list of options, or NULL. |
References CPLError(), and EQUAL.