- Properties specific to gglConnection variables
- Prerequisites for OAuth 2.0 authentication
- Connection persistence
- Functions that use a gglConnection variable
- Functions (prefix syntax) that handle gglConnection variables
gglConnection (Type of variable)
In french: gglConnexion
type is used to describe a connection to the Google services and to manage the authentication to different services. The characteristics of this connection can be defined and changed using different WLanguage properties.
: For more details on the declaration of this type of variable and the use of WLanguage properties, see Declaring a variable
Cnt is gglConnection
Cnt.Email = "email@example.com"
Cnt.ClientID = "387756281032-qffa6dajjd5348iqhi558dkd98xxxxxx.apps.googleusercontent.com"
Cnt.ClientSecret = "S13DCA6KkYh1EgPv9-jLxxxh"
IF GglConnect(Cnt) = False THEN
Properties specific to gglConnection variables
The following properties can be used to handle a Google connection:
|Name||Type used ||Effect|
|ClientID||Character string||Client identifier given when declaring the application in the Google console. |
|ClientSecret||Character string||Secret code of the client given when declaring the application in the Google console.|
|Email||Character string||Email of final client. This property is optional. This property is used to pre-fill the login window of the client to his Google account. |
Caution: This property cannot be used to retrieve the email account of the authenticated account.
Prerequisites for OAuth 2.0 authentication
- Click "Create a project". Give the name of your project. An identifier is automatically proposed for your project.
- The project is created.
- In the menu on the left, click "API and authentication" then "API".
- Choose the services required by the application:
- To access the calendars, choose "Calendar API" ("Google Apps APIs" category).
- To access the contacts, choose "Contacts API" ("Google Apps APIs" category).
- To access the Google documents, choose "Drive API" ("Google Apps APIs" category).
- To access the Picasa albums and the documents, there is no need to select a specific API.
- In the menu on the left, click "Identifiers".
- Then, click the "Create a client identifier" button.
- Select the type of application: "Application installed".
- The authorization screen must be configured during the first creation of client identifier.
- In the authorisation screen, in the "Product name" area, enter the name of your application for example.
- Click "Save".
- The screen for creating the client identifier is re-displayed.
- Validate. The client identifiers are created:
- Client identifier. This identifier must be stored. It will be used in the gglConnection variable.
- Secret code of client. This identifier must be stored. It will be used in the gglConnection variable.
When connecting to the Google services, the authentication tokens are not saved. It is therefore necessary to log in again and allow access to the application each time it is run (i.e. each time a "blank" gglConnection
variable is used).
In order for the access authorization to be persistent, all you have to do is call the serialization functions of WLanguage.
Example for implementing the persistence by using an XML file:
let sAuthPersistenceFile = SysDir(srLocalAppData) + [fSep] + "gglauth.xml"
cnt is gglConnection
// If connection already established
IF fFileExist(sAuthPersistenceFile) THEN
// Restore the connection
let bufDeserialize = fLoadBuffer(sAuthPersistenceFile)
Deserialize(cnt, bufDeserialize, psdXML)
// New connection
cnt.Email = "firstname.lastname@example.org"
cnt.ClientID = "387756281032-qffa6dajjd5348iqhi558xxxxxxxx.apps.googleusercontent.com"
cnt.ClientSecret = "Sxxxxx-jLMwwh"
IF GglConnect(cnt, gglCalendarService) THEN
// Save the connection in order to re-use it later
bufSerialize is Buffer
Serialize(cnt, bufSerialize, psdXML)
Remark: The authentication tokens of a gglConnection
variable can be cleared via GglDisconnect
Functions that use a gglConnection variable
All the functions for communicating with the Google services take a gglConnection
variable as parameter.
|GglConnect||Manages authentication on a Google server (via the "OAuth 2.0" authentication mode).|
|GglDelete||Deletes data from the Google server.|
|GglDisconnect||Disconnects the user from the Google services used. During the next re-connection, the authorizations linked to the Google services will be asked again.|
|GglFillCalendar||Fills a calendar that was retrieved beforehand: the events corresponding to the calendar are retrieved (some criteria may be specified).|
|GglFillCalendarByRequest||Fills a calendar that was retrieved beforehand: the events corresponding to the calendar are retrieved from a custom request.|
|GglGetCalendar||Retrieves a Google calendar and its events according to its title or identifier.|
|GglGetDocument||Downloads a document from the Google Docs service.|
|GglListCalendar||Retrieves the list of Google calendars associated with the specified Google account.|
|GglListContact||Retrieves the list of contacts associated with the specified Google account.|
|GglListContactByRequest||Retrieves a list of contacts from custom parameters.|
|GglListContactGroup||Retrieves the list of groups of contacts associated with the specified Google account.|
|GglListDocument||Retrieves the list of documents available on the Google server for the current user.|
|GglRequest||Sends a communication request (HTTP request) to a Google service.|
|GglUploadDocument||Uploads a document to the Google server.|
|GglWrite||Creates and/or updates data on the Google server (addition or modification of data).|
Functions (prefix syntax) that handle gglConnection variables
This page is also available for…