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.
WINDEV
WindowsLinuxUniversal Windows 10 AppJavaReportes y ConsultasCódigo de Usuario (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Código Navegador
WINDEV Mobile
AndroidWidget Android iPhone/iPadIOS WidgetApple WatchMac CatalystUniversal Windows 10 App
Otros
Procedimientos almacenados
Actualiza un usuario OAuth2 Token cuando expire.
Ejemplo
// OAuth session
SessionToken is AuthToken // OAuth session
bufToken is Buffer
sAuthPersistenceFile is string = fDataDir() + [fSep] + "AuthSession.bin"
// OAuth connection parameters
m_Svc is OAuth2Parameters         // OAuth Service (Login)
m_Svc.ClientID = "my_client_id"
m_Svc.ClientSecret = "123456-my_client_secret-387854"
m_Svc.AuthURL = "https://api.server.com/connect/authorize"
m_Svc.TokenURL = "https://api.server.com/connect/token"
m_Svc.Scope = "openid profile offline_access"
m_Svc.RedirectionURL = "http://localhost:3333"
 
// or
// m_Svc IS OpenIDParameters         // Service OAuth (Login)
// m_Svc.ClientID = "my_client_id"
// m_Svc.ClientSecret = "123456-my_client_secret-387854"
// m_Svc.ConfigurationURL = "https://api.server.com/.well-known/openid-configuration"
// m_Svc.RedirectionURL = "http://localhost:3333"
 
// Token previously stored?
IF fFileExist(sAuthPersistenceFile) THEN
WHEN EXCEPTION IN
// Loads the session
bufToken = fLoadBuffer(sAuthPersistenceFile)
Deserialize(SessionToken, bufToken, psdBinary)            
DO
// Unable to read token again
ToastDisplay("Invalid stored session")
ELSE
// Token has expired or will expire in the next minute
// and it is renewable?  
IF (SessionToken.ExpirationDate-1min < SysDateTime()) _AND_
SessionToken.Refresh <> "" THEN
SessionToken = SessionToken.RefreshToken()
IF SessionToken.Valid THEN
Serialize(SessionToken, bufToken, psdBinary)
fSaveBuffer(sAuthPersistenceFile, bufToken)
ELSE
Error("Unable to refresh session")
END
END
END
END
IF NOT SessionToken.Valid THEN
// Connect to the service
SessionToken = AuthIdentify(m_Svc)    
IF SessionToken.Valid THEN
// Save token
Serialize(SessionToken, bufToken, psdBinary)
fSaveBuffer(sAuthPersistenceFile, bufToken)
END
END
IF NOT SessionToken.Valid THEN
Error("Unable to open the session", ErrorInfo())
ELSE
MyIdentity is OpenIDIdentity = OpenIDReadIdentity(SessionToken)
IF MyIdentity.Valid THEN
// The information that can be retrieved about the identity of the connected user
// depend on the site that used for the authentication
Info("Connection successful: " + MyIdentity.Source)
ELSE
Info("Valid connection, but invalid identity ", InfoError())
END
END
Sintaxis
<Result> = <Token>.RefreshToken()
<Result>: AuthToken Variable
AuthToken variable que corresponde al token refrescado.
<Token>: AuthToken Variable
Nombre de la AuthToken Variable que corresponde al Token a refrescar. Esta Token es devuelta por AuthIdentify, por ejemplo.
Observaciones
Algunas fichas no pueden ser refrescadas. El Refresh Property del AuthToken Variable puede utilizarse para determinar si el Token puede ser refrescado.
Componente: wd280ggl.dll
Versión mínima requerida
  • Versión 26
Esta página también está disponible para…
Comentarios
Haga clic en [Agregar] para publicar un comentario