Help / WLanguage / WLanguage functions / Communication / Google functions
  • Using GglConnect (from version 20 or from the update 19 - 89795)
GglConnect (Example)
Using GglConnect (from version 20 or from the update 19 - 89795)
This example is using the "OAuth 2.0" authentication mode.
googleConnection is gglConnection
googleConnection.Email = gsGoogleAccount
// in the following format:
googleConnection.ClientID = gsGoogleClientID
// in the following format:
googleConnection.ClientSecret = gsGoogleClientSecret
// in the following format: kshKqXQPxUWmGLDiyBcmrCR2
// To create an ID and a Secret, you must:
// 1 - Own a Google account
// (not necessarily the one to which we connect,
// it will be the account associated with this application)
// 2 - Create a project in the Google console (
// 3 - Create a project in the console by specifying the requested identifier
// (with the Google restrictions: between 6 and 30 characters, lowercase only, ...)
// note: it is not this identifier that will be used
// 4 - Select the project in the Google console and choose "Enable an API",
// and enable "Calendar API" (and "Contact API" if you are using the contacts)
// 5 - In the console, go to "Identifier" then "Create a client identifier",
// and "Application installed"
// ==> Google gives the identifier and the secret key
// Store and restore (if necessary) the connection information
// to avoid having to re-ask for the authorization at each connection
bufGoogleConnection is Buffer
sGoogleTokenFileName is string = fDataDir() + "\googletoken.bin"
// Was a connection stored beforehand?
IF fFileExist(sGoogleTokenFileName) THEN
// Restore the connection iwth its authorizations
// to avoid having to re-ask for the authorizations each time
Deserialize(googleConnection, fLLoadBuffer(sGoogleTokenFileName), psdBinary)
// The deserialization failed,
// the file may be damaged
// => a new authentication request will be asked to the user
// Connect to the Google account
// ==> The first time, the user will have to validate an authentication window
IF NOT GglConnect(googleConnection, gglServiceCalendar) THEN
   // Deletes the file that contains the previous token
// (the connection failed: therefore the token is invalid)
IF fFileExist(sGoogleTokenFileName) THEN fDelete (sGoogleTokenFileName)
// Clears the gglConnection variable
// Note: you will need to assign a value again to
// the Email, ClientID and ClientSecret properties
// before re-establishing the connection
// Store the Google connection with the authorization information
Serialize(googleConnection, bufGoogleConnection, psdBinary)
fSaveBuffer(sGoogleTokenFileName, bufGoogleConnection)
// Retrieve the default calendar
ExistingCalendar is gglCalendar
ExistingCalendar = GglGetCalendar(googleConnection)
IF ErrorOccurred THEN
Info("Calendar retrieved!")
Minimum version required
  • Version 14
This page is also available for…
Click [Add] to post a comment

Last update: 05/26/2022

Send a report | Local help