Experimental project

This is a sandbox project, which contains experimental code for developer use only.

This module is now merged with http://drupal.org/project/gauth

This module allows you to authenticate with google and use this authentication to carry other api requests. This module don't have functionality of its own but can help you to manage accounts, authenticate with google (i.e. get access token) and use this authentication to carry api requests in other modules. This module allows you to enter google account details like client id, client secret key, developer key, select google services to be enabled and gets the OAuth2 access token from google. The account manage page also shows a authenticate link if the account is not authenticated (this can be helpful to authenticate later if the account is created by google_oauth2_account_save) and shows a Revoke link if the account is already authenticated and you want to revoke access.

This module is based on google api php client refer http://code.google.com/p/google-api-php-client/

You can refer more at https://developers.google.com/accounts/docs/OAuth2Login#scopeparameter and https://developers.google.com/accounts/docs/OAuth2 for Google OAuth2.
You can manage multiple google account on drupal site and use any of these accounts to carry a request to the google apis in other modules.

Requirements

Google Account Api Access Configuration
You need to create a client id account at https://code.google.com/apis/console, in api access.
Add your site domain like http://mysite.com and set the redirect url as http://mysite.com/google_oauth2/response_handler

Api access

$client = google_oauth2_client_get(account_name);

This function will return a Google_client object. You can use this client object to make api request. You can pass account array instead of account_name which has client_id, client_secret, developer_key, access_token.

$account = google_oauth2_account_load(account_name);

This functions return a account variable which will have the client_id, client_secret key, developer_key, services and importantly the access_token. You can use these variables to make a google client object and make services call depending on services enabled for the account.

google_oauth2_account_delete(account_name);

This function will allow you to delete an existing managed account from drupal site.
Note: No google account will be deleted.

google_oauth2_account_save(account_array);

This function will allow you to save any existing managed account or create a new account in drupal site. It expects an array of account as
id if you want to update the account
name Name of the account
client_id Client Id of the account
client_secret Clients secret key
developer_key Api Key of the account
services Array or comma(,) separated string which has a list of services. Names should be as "calendar,drive" refer function google_oauth2_google_services_names() in the module for these names.
Note: Account saved or created using this api will not be authenticated but you will need to call authenticate_api.

google_oauth2_account_authenticate(account_name);

This function allows you to authenticate the account with google and get access token from google.

google_oauth2_account_token_revoke(account_name);

This function allows you to unauthenticate the account with google i.e revoke access token from accessing services google.

google_oauth2_account_is_authenticated(account_name);

This function checks if the account is authenticated or not.

Project information