PC SOFT

ONLINE HELP
FOR WINDEV, WEBDEV AND WINDEV MOBILE

Home | Sign in | English US
  • Possible error cases:
  • Prerequisites for the OAuth 2.0 authentication
  • OAuth 2.0 authentication
  • Persistence of connection
  • Syntax compatible until April 2015 (can be used with the versions earlier than version 20)
WINDEV
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadApple WatchUniversal Windows 10 AppWindows Mobile
Others
Stored procedures
Allows you to perform an authentication beside a Google server. This function is automatically run when running a Gglxxx function.
Notes:
  • We recommend that you use GglConnect (syntax 2) to group the authorizations requests made by Google.
  • The disconnection is automatically performed when closing the application.
  • Versions 20 and later
    WEBDEV - Server code If your project is using cached sessions, this function must not be used in the "Initializing project" process but in the "Initializing project after connection to the site" process.
    New in version 20
    WEBDEV - Server code If your project is using cached sessions, this function must not be used in the "Initializing project" process but in the "Initializing project after connection to the site" process.
    WEBDEV - Server code If your project is using cached sessions, this function must not be used in the "Initializing project" process but in the "Initializing project after connection to the site" process.
Warning
From version 20, this feature evolves. Indeed, the authentication mode beside the Google server used the "ClientLogin" API in the earlier versions. This API will no longer be accessible from April 2015. Only the "OAuth 2.0" authentication mode will be available. This authentication mode requires:
  • the declaration of the application in the Google console,
  • the use of new properties in the gglConnection variable.
gglConnect evolves to propose the "OAuth 2.0" authentication mode in version 20.
// CAUTION: FROM VERSION 20, THE GGLCONNECTION TYPE CHANGES
// Connection by using the "OAuth 2.0" authentication mode
Cnt is gglConnection
Cnt..Email = "email_final_user@gmail.com"
Cnt..ClientID = "387756281032-qffa6dajjd5348iqhi558dkd98xxxxxx.apps.googleusercontent.com"
Cnt..ClientSecret = "S13DCA6KkYh1EgPv9-jLxxxh"
// During the connection, the user will have to validate the services used
// (See the additional examples for more details)
IF GglConnect(Cnt) = False THEN
Error(ErrorInfo())
END
// ----------------------------------------------
// SYNTAX OBSOLETE FROM NOVEMBER 2014 FOR THE CALENDARS
// AND OBSOLETE FROM APRIL 2015 FOR THE OTHER GOOGLE FUNCTIONS
// ----------------------------------------------
// Connection by using the ClientLogin API
Cnt is gglConnection
Cnt..Email = "vince@gmail.com"
Cnt..Password = "azerty"
Cnt..ApplicationName = "MyApp-03"
IF GglConnect(Cnt) = False THEN
Error(ErrorInfo())
END
Syntax

Connecting with the basic authentication Hide the details

<Result> = GglConnect(<Google Connection>)
<Result>: Boolean
  • True if the authentication was performed,
  • False if a problem occurred. To find out the error details, use ErrorInfo.
<Google Connection>: gglConnection variable
Name of gglConnection variable to use.
Versions 20 and later
Caution: the properties of the gglConnection variable must be revised for the OAuth 2.0 authentication.
New in version 20
Caution: the properties of the gglConnection variable must be revised for the OAuth 2.0 authentication.
Caution: the properties of the gglConnection variable must be revised for the OAuth 2.0 authentication.
Versions 20 and later

Connecting by specifying the services used Hide the details

<Result> = GglConnect(<Google Connection> , <Google Service>)
<Result>: Boolean
  • True if the authentication was performed,
  • False if a problem occurred. To find out the error details, use ErrorInfo.
<Google Connection>: gglConnection variable
Name of gglConnection variable to use.
<Google Service>: Integer constant (or combination of constants)
Google service to enable (the application must access these services):
gglServiceCalendar"Google Calendar" service: Google calendar
gglServiceContacts"Google Contacts" service: Management of Google contacts
gglServiceDocuments"Google Documents List" service: Management of documents
gglServicePicasa"Picasa" service
New in version 20

Connecting by specifying the services used Hide the details

<Result> = GglConnect(<Google Connection> , <Google Service>)
<Result>: Boolean
  • True if the authentication was performed,
  • False if a problem occurred. To find out the error details, use ErrorInfo.
<Google Connection>: gglConnection variable
Name of gglConnection variable to use.
<Google Service>: Integer constant (or combination of constants)
Google service to enable (the application must access these services):
gglServiceCalendar"Google Calendar" service: Google calendar
gglServiceContacts"Google Contacts" service: Management of Google contacts
gglServiceDocuments"Google Documents List" service: Management of documents
gglServicePicasa"Picasa" service

Connecting by specifying the services used Hide the details

<Result> = GglConnect(<Google Connection> , <Google Service>)
<Result>: Boolean
  • True if the authentication was performed,
  • False if a problem occurred. To find out the error details, use ErrorInfo.
<Google Connection>: gglConnection variable
Name of gglConnection variable to use.
<Google Service>: Integer constant (or combination of constants)
Google service to enable (the application must access these services):
gglServiceCalendar"Google Calendar" service: Google calendar
gglServiceContacts"Google Contacts" service: Management of Google contacts
gglServiceDocuments"Google Documents List" service: Management of documents
gglServicePicasa"Picasa" service
Remarks

Possible error cases:

  • The Internet connection is not valid.
  • The authentication was not performed properly.
Versions 20 and later

Prerequisites for the 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.
      • WINDEVWindows Mobile For the WINDEV and WINDEV Mobile applications, select "Application installed" then "Other".
      • WEBDEV - Server code For the WEBDEV sites, select "Web application". In the "Authorized redirection URI" area, enter the address of the Web server where your site is installed followed by "/WD220AWP/WD220Awp.exe/GGLCONNECT_RETURN". The syntax has the following type:
        http[s]://<Server_Name_or_IP>[:<Port>]/WD220AWP/WD220Awp.exe/GGLCONNECT_RETURN

        For example:
        • In test mode, with a Web server configured on the default port (80):
          http://localhost/WD220AWP/WD220Awp.exe/GGLCONNECT_RETURN
        • In test mode, with a Web server configured on port 8080:
          http://localhost:8080/WD220AWP/WD220Awp.exe/GGLCONNECT_RETURN
        • In Internet deployment, with a Web server configured on the default port with "www.mydomain.com" as domain:
          http://www.mydomain.com/WD220AWP/WD220Awp.exe/GGLCONNECT_RETURN
        • In Internet deployment, with a Web server configured in https on the default port (443) with "www.mydomain.com" as domain:
          https://www.mydomain.com/WD220AWP/WD220Awp.exe/GGLCONNECT_RETURN
        • In Intranet deployment, with a Web server configured on port 81 with "IntranetServer" as computer name:
          http://IntranetServer:81/WD220AWP/WD220Awp.exe/GGLCONNECT_RETURN

          where <DomainName> corresponds to the name of the site domain.
    • 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.
      • WINDEVWINDEV Mobile Redirection URI. Check whether "http://localhost" is specified.
New in version 20

Prerequisites for the 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.
      • WINDEVWindows Mobile For the WINDEV and WINDEV Mobile applications, select "Application installed" then "Other".
      • WEBDEV - Server code For the WEBDEV sites, select "Web application". In the "Authorized redirection URI" area, enter the address of the Web server where your site is installed followed by "/WD220AWP/WD220Awp.exe/GGLCONNECT_RETURN". The syntax has the following type:
        http[s]://<Server_Name_or_IP>[:<Port>]/WD220AWP/WD220Awp.exe/GGLCONNECT_RETURN

        For example:
        • In test mode, with a Web server configured on the default port (80):
          http://localhost/WD220AWP/WD220Awp.exe/GGLCONNECT_RETURN
        • In test mode, with a Web server configured on port 8080:
          http://localhost:8080/WD220AWP/WD220Awp.exe/GGLCONNECT_RETURN
        • In Internet deployment, with a Web server configured on the default port with "www.mydomain.com" as domain:
          http://www.mydomain.com/WD220AWP/WD220Awp.exe/GGLCONNECT_RETURN
        • In Internet deployment, with a Web server configured in https on the default port (443) with "www.mydomain.com" as domain:
          https://www.mydomain.com/WD220AWP/WD220Awp.exe/GGLCONNECT_RETURN
        • In Intranet deployment, with a Web server configured on port 81 with "IntranetServer" as computer name:
          http://IntranetServer:81/WD220AWP/WD220Awp.exe/GGLCONNECT_RETURN

          where <DomainName> corresponds to the name of the site domain.
    • 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.
      • WINDEVWINDEV Mobile Redirection URI. Check whether "http://localhost" is specified.

Prerequisites for the 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.
      • WINDEVWindows Mobile For the WINDEV and WINDEV Mobile applications, select "Application installed" then "Other".
      • WEBDEV - Server code For the WEBDEV sites, select "Web application". In the "Authorized redirection URI" area, enter the address of the Web server where your site is installed followed by "/WD220AWP/WD220Awp.exe/GGLCONNECT_RETURN". The syntax has the following type:
        http[s]://<Server_Name_or_IP>[:<Port>]/WD220AWP/WD220Awp.exe/GGLCONNECT_RETURN

        For example:
        • In test mode, with a Web server configured on the default port (80):
          http://localhost/WD220AWP/WD220Awp.exe/GGLCONNECT_RETURN
        • In test mode, with a Web server configured on port 8080:
          http://localhost:8080/WD220AWP/WD220Awp.exe/GGLCONNECT_RETURN
        • In Internet deployment, with a Web server configured on the default port with "www.mydomain.com" as domain:
          http://www.mydomain.com/WD220AWP/WD220Awp.exe/GGLCONNECT_RETURN
        • In Internet deployment, with a Web server configured in https on the default port (443) with "www.mydomain.com" as domain:
          https://www.mydomain.com/WD220AWP/WD220Awp.exe/GGLCONNECT_RETURN
        • In Intranet deployment, with a Web server configured on port 81 with "IntranetServer" as computer name:
          http://IntranetServer:81/WD220AWP/WD220Awp.exe/GGLCONNECT_RETURN

          where <DomainName> corresponds to the name of the site domain.
    • 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.
      • WINDEVWINDEV Mobile Redirection URI. Check whether "http://localhost" is specified.
Versions 20 and later

OAuth 2.0 authentication

The call to GglConnect triggers:
  1. The opening of a login window for the end user. If the ..Email property of the gglConnection variable is specified, Google fills the connection window with the specified email address beforehand. The login window is not displayed if the user is already connected.
  2. The opening of the authorisation window. The end user must allow the application to access his account. This window is automatically closed when the user accepts or cancels.
Notes:
  • If the syntax 1 is used (connection with basic authentication), an authorization window will be displayed whenever an attempt is performed to access a new service.
  • If the syntax 2 is used (connection by specifying the services used), an authorization window will be displayed for all the services requested at the beginning of the application.
  • The authorization window can be displayed during the first application start if the persistence of connection is managed (see next paragraph).
  • Windows Mobile Caution: The authentication is not possible with Internet Explorer (browser too old). A recent browser must be used (Opera Mobile for example).
WEBDEV - Server code Limitations: The OAuth 2.0 authentication is not supported if the connection requires interactivity (validation of Google pages):
  • In the Webservices.
  • In Ajax.
  • In the scheduled WEBDEV tasks.
  • In the delayed WEBDEV tasks.
  • In the threads.
In this case, we recommend that you use the persistence of connection.
Caution: The session time-out is also applied when displaying the Google connection pages.
New in version 20

OAuth 2.0 authentication

The call to GglConnect triggers:
  1. The opening of a login window for the end user. If the ..Email property of the gglConnection variable is specified, Google fills the connection window with the specified email address beforehand. The login window is not displayed if the user is already connected.
  2. The opening of the authorisation window. The end user must allow the application to access his account. This window is automatically closed when the user accepts or cancels.
Notes:
  • If the syntax 1 is used (connection with basic authentication), an authorization window will be displayed whenever an attempt is performed to access a new service.
  • If the syntax 2 is used (connection by specifying the services used), an authorization window will be displayed for all the services requested at the beginning of the application.
  • The authorization window can be displayed during the first application start if the persistence of connection is managed (see next paragraph).
  • Windows Mobile Caution: The authentication is not possible with Internet Explorer (browser too old). A recent browser must be used (Opera Mobile for example).
WEBDEV - Server code Limitations: The OAuth 2.0 authentication is not supported if the connection requires interactivity (validation of Google pages):
  • In the Webservices.
  • In Ajax.
  • In the scheduled WEBDEV tasks.
  • In the delayed WEBDEV tasks.
  • In the threads.
In this case, we recommend that you use the persistence of connection.
Caution: The session time-out is also applied when displaying the Google connection pages.

OAuth 2.0 authentication

The call to GglConnect triggers:
  1. The opening of a login window for the end user. If the ..Email property of the gglConnection variable is specified, Google fills the connection window with the specified email address beforehand. The login window is not displayed if the user is already connected.
  2. The opening of the authorisation window. The end user must allow the application to access his account. This window is automatically closed when the user accepts or cancels.
Notes:
  • If the syntax 1 is used (connection with basic authentication), an authorization window will be displayed whenever an attempt is performed to access a new service.
  • If the syntax 2 is used (connection by specifying the services used), an authorization window will be displayed for all the services requested at the beginning of the application.
  • The authorization window can be displayed during the first application start if the persistence of connection is managed (see next paragraph).
  • Windows Mobile Caution: The authentication is not possible with Internet Explorer (browser too old). A recent browser must be used (Opera Mobile for example).
WEBDEV - Server code Limitations: The OAuth 2.0 authentication is not supported if the connection requires interactivity (validation of Google pages):
  • In the Webservices.
  • In Ajax.
  • In the scheduled WEBDEV tasks.
  • In the delayed WEBDEV tasks.
  • In the threads.
In this case, we recommend that you use the persistence of connection.
Caution: The session time-out is also applied when displaying the Google connection pages.
Versions 20 and later

Persistence of connection

During the connection to the Google services, the authentication tokens are not saved. Therefore, you will have to re-log and to re-allow the access to the application whenever the application is run (which means whenever 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
Note: The authentication tokens of a gglConnection variable can be cleared via GglDisconnect.
New in version 20

Persistence of connection

During the connection to the Google services, the authentication tokens are not saved. Therefore, you will have to re-log and to re-allow the access to the application whenever the application is run (which means whenever 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
Note: The authentication tokens of a gglConnection variable can be cleared via GglDisconnect.

Persistence of connection

During the connection to the Google services, the authentication tokens are not saved. Therefore, you will have to re-log and to re-allow the access to the application whenever the application is run (which means whenever 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
Note: The authentication tokens of a gglConnection variable can be cleared via GglDisconnect.

Syntax compatible until April 2015 (can be used with the versions earlier than version 20)

Until April 2015, you have the ability to use the following syntax:
<Result> = GglConnect(Google Connection>)
where <Google Connection> is a gglConnection variable containing the following properties:
NameType used Effect
EmailCharacter stringGoogle email address of user (corresponds to his login).
PasswordCharacter stringPassword for the connection.
ApplicationNameCharacter stringName of application. This property can correspond to an empty string.
// SYNTAX OBSOLETE FROM APRIL 2015

// Connection
Cnt is gglConnection
Cnt..Email = "vince@gmail.com"
Cnt..Password = "azerty"
Cnt..ApplicationName = "MyApp-03"
IF GglConnect(Cnt) = False THEN
Error(ErrorInfo())
END
Caution: From November 14 2014, this syntax can no longer be used if you are using the "Google Calendar" service. You must use the "OAuth 2.0" authentication mode available:
Components
WINDEVWEBDEV - Server codeReports and Queries wd230ggl.dll
Windows Mobile wp230ggl.dll
Minimum required version
  • Version 14
This page is also available for…
Comments
Click [Add] to post a comment