|
|
|
|
<AuthToken>.RefreshToken (Function) In french: <AuthToken>.RenouvelleToken Refreshes a user's OAuth2 token when it expires. New in version 2024
TokenSession is AuthToken
bufToken is Buffer
sFichierPersistanceAuth is string = fDataDir() + [fSep] + "AuthSession.bin"
m_Svc is OAuth2Parameters
m_Svc.ClientID = "mon_client_id"
m_Svc.ClientSecret = "123456-mon_client_secret-387854"
m_Svc.AuthURL = "https://api.serveur.com/connect/authorize"
m_Svc.TokenURL = "https://api.serveur.com/connect/token"
m_Svc.Scope = "openid profile offline_access"
m_Svc.RedirectionURL = "http://localhost:3333"
IF fFileExist(sFichierPersistanceAuth) THEN
WHEN EXCEPTION IN
bufToken = fLoadBuffer(sFichierPersistanceAuth)
Deserialize(TokenSession, bufToken, psdBinary)
DO
ToastDisplay("Session mémorisée invalide")
ELSE
IF (TokenSession.ExpirationDate-1 min < SysDateTime()) _AND_
TokenSession.Refresh <> "" THEN
TokenSession = TokenSession.RenouvelleToken()
IF TokenSession.Valid THEN
Serialize(TokenSession, bufToken, psdBinary)
fSaveBuffer(sFichierPersistanceAuth, bufToken)
ELSE
Error("Echec du renouvellement de la session")
END
END
END
END
IF NOT TokenSession.Valid THEN
TokenSession = AuthIdentify(m_Svc)
IF TokenSession.Valid THEN
Serialize(TokenSession, bufToken, psdBinary)
fSaveBuffer(sFichierPersistanceAuth, bufToken)
END
END
IF NOT TokenSession.Valid THEN
Error("Impossible de démarrer la session", ErrorInfo())
ELSE
MonIdentité is OpenIDIdentity = OpenIDReadIdentity(TokenSession)
IF MonIdentité.Valid THEN
Info("Connexion OK: " + MonIdentité.Source)
ELSE
Info("Connexion valide, mais échec identité ", ErrorInfo())
END
END
Syntax
<Result> = <Token>.RefreshToken()
<Result>: AuthToken variable AuthToken variable that corresponds to the refreshed token. <Token>: AuthToken variable Name of the AuthToken variable that corresponds to the token to be refreshed. This token is returned by AuthIdentify, for example. Remarks Some tokens cannot be refreshed. The Refresh property of the AuthToken variable can be used to determine if the token can be refreshed.
This page is also available for…
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|