AYUDA EN LÍNEA
 WINDEVWEBDEV Y WINDEV MOBILE

Este contenido se ha traducido automáticamente.  Haga clic aquí  para ver la versión en inglés.
Ayuda / WLanguage / Funciones WLanguage / Comunicación / Funciones Google / Google Calendar
  • Possible error cases:
  • Prerequisites for OAuth 2.0 authentication
  • OAuth 2.0 authentication
  • Connection persistence
WINDEV
WindowsLinuxJavaReportes y ConsultasCódigo de Usuario (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Código Navegador
WINDEV Mobile
AndroidWidget Android iPhone/iPadIOS WidgetApple WatchMac Catalyst
Otros
Procedimientos almacenados
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 <gglConnection variable>.Connect (syntax 2) to group the authorizations requests made by Google.
  • The disconnection is automatically performed when closing the application.
Ejemplo
// 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
// (For more details, see the additional examples)
IF Cnt.Connect() = False THEN
	Error(ErrorInfo())
END
Sintaxis

Conectando con la autenticación básica Ocultar los detalles

<Result> = <Google connection>.Connect()
<Result>: booleano
  • True if the authentication was performed,
  • False if a problem occurs. To get more details on the error, use ErrorInfo.
<Google connection>: Variable de tipo gglConnection
Name of the gglConnection variable to be used.

Conectarse especificando los servicios utilizados Ocultar los detalles

<Result> = <Google connection>.Connect(<Google service>)
<Result>: booleano
  • True if the authentication was performed,
  • False if a problem occurs. To get more details on the error, use ErrorInfo.
<Google connection>: Variable de tipo gglConnection
Name of the variable of type gglConnection to be used.
<Google service>: Constante o combinación de constantes de tipo Integer
Google service to enable (the application must access these services):
gglServiceCalendarService "Google Calendar": Agenda Google
gglServiceContactsService "Google Contacts": Management of Google Contacts
gglServiceDocumentsGoogle Docs List service: Document management
gglServicePicasa"Picasa" service
Observaciones

Possible error cases:

  • The Internet connection is not valid.
  • The authentication was not performed properly.

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.
      • Client secret code. This identifier must be stored. It will be used in the gglConnection variable.
      • WINDEV Redirection URI. Check whether "http://localhost" is specified.

OAuth 2.0 authentication

The call to <gglConnection variable>.Connect triggers:
  1. 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.
  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.
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 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 cnt.Connect(gglServiceCalendar) THEN
// Save the connection in order to re-use it later
bufSerialize is Buffer
Serialize(cnt, bufSerialize, psdXML)
fSaveBuffer(sAuthPersistenceFile, bufSerialize)
END

Note: It is possible to empty authentication tokens from a variable of type gglConnection variable using the <gglConnection variable>.desconectar function.
Componente: wd300ggl.dll
Versión mínima requerida
  • Versión 24
Esta página también está disponible para…
Comentarios
Haga clic en [Agregar] para publicar un comentario

Última modificación: 30/09/2024

Señalar un error o enviar una sugerencia | Ayuda local