|
|
|
|
|
- Possible error cases:
- Prerequisites for OAuth 2.0 authentication
- OAuth 2.0 authentication
- Connection persistence
GglConnect (Function) In french: GglConnecte Manages authentication on a Google server (via the "OAuth 2.0" authentication mode). This function is automatically run when running a Gglxxx function. Remarks: - 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.
- If your project uses pre-launched sessions, this function should not be used in the "Initialization" event of the project, but in the "Initialization in pre-launched session mode" event.
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
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 occurs. To get more details on the error, use ErrorInfo.
<Google connection>: gglConnection variable Name of the gglConnection variable to be used.
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 occurs. To get more details on the error, use ErrorInfo.
<Google connection>: gglConnection variable Name of the variable of type gglConnection to be used. <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.
Prerequisites for OAuth 2.0 authentication - Click "Create a project". Give the name of your project. An identifier is automatically proposed for your project.
- Validate
- 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.
- For the WEBDEV websites, select "Web application". In the "Authorized redirection URI" area, enter the address of the Web server where your site is installed followed by "/WD300AWP/WD300Awp.exe/GGLCONNECT_RETURN". The syntax has the following type:
http[s]://<Server_name_or_IP_address>[:<Port>]/WD300AWP/WD300AWP.exe/GGLCONNECT_RETURN For example: - In test mode, with a Web server configured on the default port (80):
http://localhost/WD300AWP/WD300AWP.exe/GGLCONNECT_RETURN - In test mode, with a Web server configured on port 8080:
http://localhost:8080/WD300AWP/WD300AWP.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//WD300AWP/WD300AWP.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//WD300AWP/WD300AWP.exe/GGLCONNECT_RETURN - In Intranet deployment, with a Web server configured on port 81 with "IntranetServer" as computer name:
http://IntranetServer:81/WD300AWP/WD300AWP.exe/GGLCONNECT_RETURN
- Validate. The client identifiers are created:
- Client identifier. This identifier must be stored. It will be used in the gglConnection variable.
- Client secret code. This identifier must be stored. It will be used in the gglConnection variable.
OAuth 2.0 authentication The call to GglConnect triggers: - The opening of a login window for the end user. If the Email property of the gglConnection variable is specified, Google pre-populates the connection window with the specified email address. The login window is not displayed if the user is already connected.
- 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.
Remarks: - 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).
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 fFileExist(sAuthPersistenceFile) THEN
let bufDeserialize = fLoadBuffer(sAuthPersistenceFile)
Deserialize(cnt, bufDeserialize, psdXML)
ELSE
cnt.Email = "email@gmail.com"
cnt.ClientID = "387756281032-qffa6dajjd5348iqhi558xxxxxxxx.apps.googleusercontent.com"
cnt.ClientSecret = "Sxxxxx-jLMwwh"
END
IF GglConnect(cnt, gglCalendarService) THEN
bufSerialize is Buffer
Serialize(cnt, bufSerialize, psdXML)
fSaveBuffer(sAuthPersistenceFile, bufSerialize)
END
Remark: The authentication tokens of a gglConnection variable can be cleared via GglDisconnect.
This page is also available for…
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|