Class google.accounts.user
Object
|
+--google.accounts.user
- class
google.accounts.user
Class representing state of an authenticated user session.
Defined in gdata.js
Method Summary |
string
|
checkLogin(<string> scope)
Checks whether a cookie containing a token for the specified scope exists.
|
boolean
|
getInfo(<Function> callback)
Gets detailed information related to the current token, including target
(the domain that originally requested the token) and scope.
|
string?
|
login(<string> scope)
Retrieves a valid authentication token.
|
boolean
|
logout(<Function> opt_callback)
Revokes the current authentication token and deletes all authentication
cookies for that token stored by the browser.
|
google.accounts.user
google.accounts.user()
checkLogin
string checkLogin(<string> scope)
Checks whether a cookie containing a token for the specified scope exists.
Also, sets the current scope to the specified scope, so that subsequent calls
to logout() and getInfo() use the new current scope. The
returned token is not guaranteed to be valid, so the application must be able
to handle an authorization exception when the token is used.
Parameters:
scope
- URL identifying the service to be accessed.
Returns:
A token, if one exists. If no token exists for the specified scope, this method returns an empty string.
getInfo
boolean getInfo(<Function> callback)
Gets detailed information related to the current token, including target
(the domain that originally requested the token) and scope. This method is
primarily intended for debugging purposes, because this information is not
needed to verify authentication. Unlike other AuthSub for JavaScript methods,
this method uses a callback function to asynchronously receive the requested
data. If your client application uses multiple scopes, then it should call
checkLogin() to set the appropriate scope before calling
getInfo().
Parameters:
callback
- Callback function to return information. The callback parameter should accept a single data
parameter, whose currentTarget.responseText
parameter is a JSON string. This JSON string can be turned into a JavaScript object with the following three parameters: Target
(string) A URL value identifying the domain of the web page that made the original request. Scope
(Array) An array of scopes for the token. Secure
(boolean) a Boolean value indicating whether the token is valid only for signed requests from SSL certificates registered with Google. Currently, this returned value is always false for tokens acquired using AuthSub for JavaScript.
For more usage information, visit the AuthSubJS Reference.
Returns:
Returns true if the method succeeds, false otherwise. In addition, the input callback function is called once the token info is received.
login
string? login(<string> scope)
Retrieves a valid authentication token. This method first checks whether or
not a cookie for the specified scope is already stored in the browser. If one
is found, the token value is returned. If no cookie is found, a request is
sent to the authentication service, which shows the user a Google Accounts
Request Access page. If the user successfully logs in and grants access, then
cookies containing scope and token are stored in the client browser, and the
token value is returned to the calling function.
Parameters:
scope
- URL identifying the service to be accessed.
Returns:
Returns a token, keyed to a specific combination of user, client application domain, and Google service scope, or null
if the scope is empty, or the token is invalid. In addition, if no valid token exists in the client browser, then the user is redirected to a Google page and invited to log into their Google account and authorize access by the web application.
logout
boolean logout(<Function> opt_callback)
Revokes the current authentication token and deletes all authentication
cookies for that token stored by the browser. The Google service refuses
subsequent requests for access until your client acquires a new token. If
your client application uses multiple scopes, then it should call
checkLogin() to set the appropriate scope before calling
logout().
Parameters:
opt_callback
- An optional callback method to invoke after the user is logged out.
Returns:
Returns false if user already logged out.
Documentation generated by
JSDoc on Wed Dec 10 17:19:28 2008