PC SOFT

ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Home | Sign in | English EN
  • Properties specific to the description of gglConnection variables
  • Prerequisites for OAuth 2.0 authentication
  • Connection persistence
  • Functions that use a gglConnection variable
  • Functions (prefix syntax) that handle gglConnection variables
WINDEV
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac CatalystUniversal Windows 10 App
Others
Stored procedures
gglConnection (Type of variable)
In french: gglConnexion
The gglConnection 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.
Remark: For more details on the declaration of this type of variable and the use of WLanguage properties, see Declaring a variable.
Example
// Connection
Cnt is gglConnection
Cnt.Email = "email_final_user@gmail.com"
Cnt.ClientID = "387756281032-qffa6dajjd5348iqhi558dkd98xxxxxx.apps.googleusercontent.com"
Cnt.ClientSecret = "S13DCA6KkYh1EgPv9-jLxxxh"
IF GglConnect(Cnt) = False THEN
Error(ErrorInfo())
END
Remarks

Properties specific to the description of gglConnection variables

The following properties can be used to handle a Google connection:
NameType used Effect
ClientIDCharacter stringClient identifier given when declaring the application in the Google console.
ClientSecretCharacter stringSecret code of the client given when declaring the application in the Google console.
EmailCharacter stringEmail 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

To connect with the OAuth 2.0 authentication, the application must be declared on your Google developer console: https://developers.google.com/console. In the console:
  1. Click "Create a project". Give the name of your project. An identifier is automatically proposed for your project.
  2. Validate
  3. The project is created.
  4. In the menu on the left, click "API and authentication" then "API".
  5. 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.
  6. In the menu on the left, click "Identifiers".
  7. 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.
      • WINDEV For WINDEV applications, select "Installed application", then "Other".
    • 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.
      • WINDEV Redirection URI. Check whether "http://localhost" is specified.

Connection persistence

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)
ELSE
// New connection
cnt.Email = "email@gmail.com"
cnt.ClientID = "387756281032-qffa6dajjd5348iqhi558xxxxxxxx.apps.googleusercontent.com"
cnt.ClientSecret = "Sxxxxx-jLMwwh"
END
 
IF GglConnect(cnt, gglCalendarService) THEN
// Save the connection in order to re-use it later
bufSerialize is Buffer
Serialize(cnt, bufSerialize, psdXML)
fSaveBuffer(sAuthPersistenceFile, bufSerialize)
END

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.
GglConnectManages authentication on a Google server (via the "OAuth 2.0" authentication mode).
GglDisconnectDisconnects the user from the Google services used. During the next re-connection, the authorizations linked to the Google services will be asked again.
GglWriteCreates and/or updates data on the Google server (addition or modification of data).
GglUploadDocumentUploads a document to the Google server.
GglListCalendarRetrieves the list of Google calendars associated with the specified Google account.
GglListContactRetrieves the list of contacts associated with the specified Google account.
GglListContactByRequestRetrieves a list of contacts from custom parameters.
GglListDocumentRetrieves the list of documents available on the Google server for the current user.
GglListContactGroupRetrieves the list of groups of contacts associated with the specified Google account.
GglGetCalendarRetrieves a Google calendar and its events according to its title or identifier.
GglGetDocumentDownloads a document from the Google Docs service.
GglFillCalendarFills a calendar that was retrieved beforehand: the events corresponding to the calendar are retrieved (some criteria may be specified).
GglFillCalendarByRequestFills a calendar that was retrieved beforehand: the events corresponding to the calendar are retrieved from a custom request.
GglRequestSends a communication request (HTTP request) to a Google service.
GglDeleteDeletes data from the Google server.

Functions (prefix syntax) that handle gglConnection variables

<gglConnection variable>.ConnectManages authentication on a Google server (via the "OAuth 2.0" authentication mode).
<gglConnection variable>.DisconnectDisconnects the user from the Google services used. During the next re-connection, the authorizations linked to the Google services will be asked again.
<gglConnection variable>.WriteCreates and/or updates data on the Google server (addition or modification of data).
<gglConnection variable>.UploadDocumentUploads a document to the Google server.
<gglConnection variable>.ListCalendarRetrieves the list of Google calendars associated with the specified Google account.
<gglConnection variable>.ListContactByRequestRetrieves a list of contacts from custom parameters.
<gglConnection variable>.ListContactRetrieves the list of contacts associated with the specified Google account.
<gglConnection variable>.ListDocumentRetrieves the list of documents available on the Google server for the current user.
<gglConnection variable>.ListContactGroupRetrieves the list of groups of contacts associated with the specified Google account.
<gglConnection variable>.GetCalendarRetrieves a Google calendar and its events according to its title or identifier.
<gglConnection variable>.GetDocumentDownloads a document from the Google Docs service.
<gglConnection variable>.FillCalendarByRequestFills a calendar that was retrieved beforehand: the events corresponding to the calendar are retrieved from a custom request.
<gglConnection variable>.FillCalendarFills a calendar that was retrieved beforehand: the events corresponding to the calendar are retrieved (some criteria may be specified).
<gglConnection variable>.RequestSends a communication request (HTTP request) to a Google service.
<gglConnection variable>.DeleteDeletes data from the Google server.
Minimum version required
  • Version 14
This page is also available for…
Comments
Click [Add] to post a comment