Packagecom.distriqt.extension.googleidentity
Classpublic final class GoogleIdentity
InheritanceGoogleIdentity Inheritance flash.events.EventDispatcher

This class represents the GoogleIdentity extension.

Allows you to sign in user's to your application via their Google account and access Google APIs on their behalf if required.



Public Properties
 PropertyDefined By
  implementation : String
[read-only] The implementation currently in use.
GoogleIdentity
  isSupported : Boolean
[static] [read-only] Whether the current device supports the extensions functionality
GoogleIdentity
  nativeVersion : String
[read-only] The native version string of the native extension.
GoogleIdentity
  service : GoogleIdentity
[static] [read-only] The singleton instance of the GoogleIdentity class.
GoogleIdentity
  version : String
[read-only] The version of this extension.
GoogleIdentity
Public Methods
 MethodDefined By
  
Constructor You should not call this directly, but instead use the singleton access
GoogleIdentity
  
disconnect():Boolean
Disconnects the current user from the app and revokes previous authentication.
GoogleIdentity
  
dispose():void
Disposes the extension and releases any allocated resources.
GoogleIdentity
  
getToken(clientSecret:String):Boolean
Deprecated: This has been deprecated as it is against best practice to use an access token on a device
Get a valid access token and a valid ID token, refreshing them first if they have expired or are about to expire.
GoogleIdentity
  
Get the current GoogleUser.
GoogleIdentity
  
init(key:String):void
Deprecated: You no longer need to use an application key
[static] Initialises the extension class for use with the provided key.
GoogleIdentity
  
isSignedIn():Boolean
Returns true if there is a currently signed in user.
GoogleIdentity
  
Setup the Google Identity settings and initiate a connection to the API services.
GoogleIdentity
  
signIn():Boolean
Starts the user initiated sign-in process
GoogleIdentity
  
signInSilently():Boolean
If the user has previously accepted authentication etc then you can expect a silent sign in at startup to succeed.
GoogleIdentity
  
signOut():Boolean
Marks current user as being in the signed out state
GoogleIdentity
Events
 Event Summary Defined By
   Dispatched when the user has been disconnected from this application.GoogleIdentity
   An error occured error and errorCode will contain details of the error that occurred.GoogleIdentity
   Dispatched when setup is complete.GoogleIdentity
   Dispatched when sign in completes.GoogleIdentity
   Dispatched when the user has been signed out.GoogleIdentity
   Dispatched when the tokens failed to be retrieved or refreshed.GoogleIdentity
   Dispatched when a call to getToken has completed successfully The access and id tokens in the user object will now be valid.GoogleIdentity
Public Constants
 ConstantDefined By
  EXT_CONTEXT_ID : String = com.distriqt.GoogleIdentity
[static]
GoogleIdentity
  VERSION : String = 5.5.0
[static]
GoogleIdentity
Property Detail
implementationproperty
implementation:String  [read-only]

The implementation currently in use. This should be one of the following depending on the platform in use and the functionality supported by this extension:


Implementation
    public function get implementation():String
isSupportedproperty 
isSupported:Boolean  [read-only]

Whether the current device supports the extensions functionality


Implementation
    public static function get isSupported():Boolean
nativeVersionproperty 
nativeVersion:String  [read-only]

The native version string of the native extension.


Implementation
    public function get nativeVersion():String
serviceproperty 
service:GoogleIdentity  [read-only]

The singleton instance of the GoogleIdentity class.


Implementation
    public static function get service():GoogleIdentity

Throws
Error — If there was a problem creating or accessing the extension, or if the key is invalid
versionproperty 
version:String  [read-only]

The version of this extension.

This should be of the format, MAJOR.MINOR.BUILD


Implementation
    public function get version():String
Constructor Detail
GoogleIdentity()Constructor
public function GoogleIdentity()

Constructor You should not call this directly, but instead use the singleton access

Method Detail
disconnect()method
public function disconnect():Boolean

Disconnects the current user from the app and revokes previous authentication. If the operation succeeds, the OAuth 2.0 token is also removed from keychain.

Once disconnect is called you can expect signInSilently to fail.

Returns
Boolean — true if started successfully and false otherwise
dispose()method 
public function dispose():void

Disposes the extension and releases any allocated resources. Once this function has been called, a call to init is neccesary again before any of the extensions functionality will work.

getToken()method 
public function getToken(clientSecret:String):Boolean
Deprecated: This has been deprecated as it is against best practice to use an access token on a device

Get a valid access token and a valid ID token, refreshing them first if they have expired or are about to expire.

Parameters

clientSecret:String

Returns
Boolean — true if started successfully and false if the user is not signed in
getUser()method 
public function getUser():GoogleUser

Get the current GoogleUser. Will return null if there is no user signed in.

Returns
GoogleUser — The current GoogleUser or null if not signed in
init()method 
public static function init(key:String):void
Deprecated: You no longer need to use an application key

Initialises the extension class for use with the provided key.

Parameters

key:String


Throws
Error — If there was a problem creating or accessing the extension, or if the key is invalid
isSignedIn()method 
public function isSignedIn():Boolean

Returns true if there is a currently signed in user.

Returns
Booleantrue if a user is signed in and false if not.
setup()method 
public function setup(options:GoogleIdentityOptions):void

Setup the Google Identity settings and initiate a connection to the API services. Most importantly this call sets the client IDs for your application.

Parameters

options:GoogleIdentityOptions — GoogleIdentityOptions


Example
         GoogleIdentity.service.addEventListener( GoogleIdentityEvent.SETUP_COMPLETE, setupCompleteHandler );
         
         var options:GoogleIdentityOptions = new GoogleIdentityOptions( "ANDROID_CLIENT_ID", "IOS_CLIENT_ID" );
         GoogleIdentity.service.setup( options );
         
         private function setupCompleteHandler( event:GoogleIdentityEvent ):void
         {
             // Setup is complete, can call sign in etc now
             GoogleIdentity.service.signInSilently();
         }
         
signIn()method 
public function signIn():Boolean

Starts the user initiated sign-in process

Returns
Boolean — true if started successfully and false otherwise
signInSilently()method 
public function signInSilently():Boolean

If the user has previously accepted authentication etc then you can expect a silent sign in at startup to succeed. You can do this early in your application to automatically sign in returning users.

It will dispatch an ERROR event if sign in fails, generally if the user hasn't signed in previously. You should call signIn at some other point in your application.

Returns
Boolean — true if started successfully and false otherwise
signOut()method 
public function signOut():Boolean

Marks current user as being in the signed out state

Returns
Boolean — true if started successfully and false otherwise
Event Detail
googleidentity:disconnect Event
Event Object Type: com.distriqt.extension.googleidentity.events.GoogleIdentityEvent
GoogleIdentityEvent.type property = com.distriqt.extension.googleidentity.events.GoogleIdentityEvent.DISCONNECT

Dispatched when the user has been disconnected from this application.

googleidentity:error Event  
Event Object Type: com.distriqt.extension.googleidentity.events.GoogleIdentityEvent
GoogleIdentityEvent.type property = com.distriqt.extension.googleidentity.events.GoogleIdentityEvent.ERROR

An error occured

error and errorCode will contain details of the error that occurred.

- SIGN_IN_CANCELLED [12501]: The sign in was cancelled by the user. i.e. user cancelled some of the sign in resolutions, e.g. account picking or OAuth consent. - SIGN_IN_FAILED [12500]: The sign in attempt didn't succeed with the current account. Unlike SIGN_IN_REQUIRED. when seeing this error code, there is nothing user can do to recover from the sign in failure. - SIGN_IN_REQUIRED [4]: The client attempted to connect to the service but the user is not signed in. - INTERNAL_ERROR [8]: An internal error occurred. Retrying should resolve the problem. - INVALID_ACCOUNT [5]: The client attempted to connect to the service with an invalid account name specified. - NETWORK_ERROR [7]: A network error occurred. Retrying should resolve the problem.

googleidentity:setupcomplete Event  
Event Object Type: com.distriqt.extension.googleidentity.events.GoogleIdentityEvent
GoogleIdentityEvent.type property = com.distriqt.extension.googleidentity.events.GoogleIdentityEvent.SETUP_COMPLETE

Dispatched when setup is complete. You should wait for this event before attempting any other functionality.

googleidentity:signin Event  
Event Object Type: com.distriqt.extension.googleidentity.events.GoogleIdentityEvent
GoogleIdentityEvent.type property = com.distriqt.extension.googleidentity.events.GoogleIdentityEvent.SIGN_IN

Dispatched when sign in completes. user will contain a valid GoogleUser object.

At this point the access and id tokens may not be valid. If you are planning on using them you should now call getToken and listen for the completion event.

googleidentity:signout Event  
Event Object Type: com.distriqt.extension.googleidentity.events.GoogleIdentityEvent
GoogleIdentityEvent.type property = com.distriqt.extension.googleidentity.events.GoogleIdentityEvent.SIGN_OUT

Dispatched when the user has been signed out.

googleidentity:token:failed Event  
Event Object Type: com.distriqt.extension.googleidentity.events.GoogleIdentityEvent
GoogleIdentityEvent.type property = com.distriqt.extension.googleidentity.events.GoogleIdentityEvent.TOKEN_FAILED

Dispatched when the tokens failed to be retrieved or refreshed.

googleidentity:token:updated Event  
Event Object Type: com.distriqt.extension.googleidentity.events.GoogleIdentityEvent
GoogleIdentityEvent.type property = com.distriqt.extension.googleidentity.events.GoogleIdentityEvent.TOKEN_UPDATED

Dispatched when a call to getToken has completed successfully

The access and id tokens in the user object will now be valid.

Constant Detail
EXT_CONTEXT_IDConstant
public static const EXT_CONTEXT_ID:String = com.distriqt.GoogleIdentity

VERSIONConstant 
public static const VERSION:String = 5.5.0