| Package | com.myflashlab.air.extensions.gSignIn |
| Class | public class GRest |
| Inheritance | GRest Object |
This class will help you with more activities you can do with Google Auth API. If all you need is a simple
Google SignIn, you wouldn't need to use this class at all. but if you happen to need access to refresh_token or
access_token or other similar works, you will find this class helpful. To start working with GRest class, first
you must pass the Web ClientId and secret to the following properties: GSignIn.rest.webClientId,
GSignIn.rest.webClientSecret.
| Property | Defined By | ||
|---|---|---|---|
| webClientId : String [write-only]
Setter property for the Web ClientId of your application found in Google API console
| GRest | ||
| webClientSecret : String [write-only]
Setter property for the Web Client Secret of your application found in Google API console
| GRest | ||
| Method | Defined By | ||
|---|---|---|---|
getTokens($serverAuthCode:String, $callback:Function):void
Use this method to retrieve a new instance of GRestTokens class. | GRest | ||
refreshAccessToken($refreshToken:String, $callback:Function):void
You can refresh an access token without prompting the user for permission (including when the user is not
present) if you requested offline access to the scopes associated with the token. | GRest | ||
tokenInfo($idToken:String, $callback:Function):void
Use this method to retrieve information about your idToken being received after signing in. | GRest | ||
| webClientId | property |
webClientId:String [write-only] Setter property for the Web ClientId of your application found in Google API console
public function set webClientId(value:String):void| webClientSecret | property |
webClientSecret:String [write-only] Setter property for the Web Client Secret of your application found in Google API console
public function set webClientSecret(value:String):void| getTokens | () | method |
public function getTokens($serverAuthCode:String, $callback:Function):void
Use this method to retrieve a new instance of GRestTokens class.
Parameters
$serverAuthCode:String | |
$callback:Function — The callback function must expect 2 parameters, GRestTokens and Error
|
// _serverAuthCode is received from the GAccount object after the GSignIn.signin(); call
GSignIn.rest.getTokens(_serverAuthCode, onTokensResult);
function onTokensResult($restTokens:GRestTokens, $error:Error):void
{
if($error)
{
trace($error.message);
return;
}
trace("------------------------------");
trace("access_token: " + $restTokens.access_token);
trace("token_type: " + $restTokens.token_type);
trace("expires_in: " + $restTokens.expires_in);
trace("refresh_token: " + $restTokens.refresh_token);
trace("id_token: " + $restTokens.id_token);
trace("------------------------------");
}
| refreshAccessToken | () | method |
public function refreshAccessToken($refreshToken:String, $callback:Function):voidYou can refresh an access token without prompting the user for permission (including when the user is not present) if you requested offline access to the scopes associated with the token.
Parameters
$refreshToken:String — The refresh token returned from the getTokens method.
| |
$callback:Function — The callback function must expect 2 parameters, Object and Error
|
GSignIn.rest.refreshAccessToken("refreshToken", onRefreshAccessTokenResult);
function onRefreshAccessTokenResult($info:Object, $error:Error):void
{
if($error)
{
trace($error.message);
return;
}
// read more about tokeninfo here:
// https://developers.google.com/identity/protocols/OAuth2InstalledApp#offline
trace("------------------------------");
trace(JSON.stringify($info));
trace("------------------------------");
}
| tokenInfo | () | method |
public function tokenInfo($idToken:String, $callback:Function):voidUse this method to retrieve information about your idToken being received after signing in.
Parameters
$idToken:String | |
$callback:Function — The callback function must expect 2 parameters, Object and Error
|
GSignIn.rest.tokenInfo("idToken", onTokensInfoResult);
function onTokensInfoResult($info:Object, $error:Error):void
{
if($error)
{
trace($error.message);
return;
}
// read more about tokeninfo here:
// https://developers.google.com/identity/sign-in/web/backend-auth#calling-the-tokeninfo-endpoint
trace("------------------------------");
trace(JSON.stringify($info));
trace("------------------------------");
}