19 décembre 2023
publié par 

Pour les applications WINDEV qui doivent interroger l'API de Twitter, l'authentification se fait par OAuth 2.0 avec PKCE ("Proof Key for Code Exchange" / "clé de preuve pour l'échange de code").

 

Ce mode d'authentification pouvait imposer plusieurs requêtes HTTPS jusqu'à la version 28. Mais PKCE a été ajouté aux options de l'authentification en version 2024 (cf. nouveauté 108).


Voici un exemple de code d'authentification complet :

 

 

Twitter_OAuth est un OAuth2Paramètres
Twitter_Token est un AuthToken

sClientID est une chaîne ANSI = "al_____aQ"
sClientSecret est une chaîne ANSI = "9Z_______XOvK"

Twitter_OAuth.ClientID = sClientID
Twitter_OAuth.ClientSecret = sClientSecret
Twitter_OAuth.URLAuth = "https://twitter.com/i/oauth2/authorize"
Twitter_OAuth.URLToken = "https://api.twitter.com/2/oauth2/token"
Twitter_OAuth.Scope = "tweet.read"
Twitter_OAuth.URLRedirection = "http://localhost:9874/"
Twitter_OAuth.TypeRéponse = oauth2TypeRéponseCode
Twitter_OAuth.Option = authPKCE

Twitter_Token = AuthIdentifie(Twitter_OAuth)

 

 

 

L'application configurée dans le portail développeur Twitter doit être en "Native app" (pas "Web App, Automated App or Bot").

 

Liens utiles sur le sujet :

 

< Retour

Publier un commentaire : 
Votre adresse email ne sera pas publiée