class AppIdentityService (View source)

The AppIdentityService allows you to sign arbitrary byte array using per app private key maintained by App Engine. You can also retrieve a list of public certificates which can be used to verify the signature.

App Engine is responsible for maintaining per-application private key. App Engine will keep rotating private keys periodically. App Engine never releases these private keys externally.

Since private keys are rotated periodically, getPublicCertificates() could return a list of public certificates. It's the caller's responsibility to try these certificates one by one when doing signature verification.

Constants

PACKAGE_NAME

PARTITION_SEPARATOR

DOMAIN_SEPARATOR

MEMCACHE_KEY_PREFIX

EXPIRY_SAFETY_MARGIN_SECS

EXPIRY_SHORT_MARGIN_SECS

Methods

static array
signForApp(string $bytes_to_sign)

Signs arbitrary byte array using per app private key.

static string
getServiceAccountName()

Get the service account name for the application.

static PublicCertificate[]
getPublicCertificates()

Get the list of public certifates for the application.

static array
getAccessToken(array $scopes)

Gets an OAuth2 access token for the application's service account from the cache or generates and caches one by calling getAccessTokenUncached($scopes)

static string
getApplicationId()

Get the application id of an app.

static string
getDefaultVersionHostname()

Get the standard hostname of the default version of the app.

Details

static array signForApp(string $bytes_to_sign)

Signs arbitrary byte array using per app private key.

Parameters

string $bytes_to_sign The bytes to generate the signature for.

Return Value

array An array containing the elements 'key_name' - the name of the key used to sign the bytes 'signature' - the signature of the bytes.

Exceptions

InvalidArgumentException If $bytes_to_sign is not a string.
AppIdentityException If there is an error using the AppIdentity service.

static string getServiceAccountName()

Get the service account name for the application.

Return Value

string The service account name.

Exceptions

AppIdentityException If there is an error using the AppIdentity service.

static PublicCertificate[] getPublicCertificates()

Get the list of public certifates for the application.

Return Value

PublicCertificate[] An array of the applications public certificates.

Exceptions

AppIdentityException If there is an error using the AppIdentity service.

static array getAccessToken(array $scopes)

Gets an OAuth2 access token for the application's service account from the cache or generates and caches one by calling getAccessTokenUncached($scopes)

Each application has an associated Google account. This function returns OAuth2 access token corresponding to the running app. Access tokens are safe to cache and reuse until they expire.

Parameters

array $scopes The scopes to acquire the access token for. Can be either a single string or an array of strings.

Return Value

array An array with the following key/value pairs. 'access_token' - The access token for the application. 'expiration_time' - The expiration time for the access token.

Exceptions

InvalidArgumentException If $scopes is not a string or an array of strings.
AppIdentityException If there is an error using the AppIdentity service.

static string getApplicationId()

Get the application id of an app.

Return Value

string The application id of the app.

static string getDefaultVersionHostname()

Get the standard hostname of the default version of the app.

Return Value

string The standard hostname of the default version of the application, or FALSE if the call failed.