Vb.net 如何撤销用户的令牌
如何为用户撤销令牌 这是我的身份验证代码,我想为一个用户重置(撤销)访问权限。这是因为我使用,我希望允许我的用户在必要时更改他们的电子邮件 实际上,令牌是在到达令牌的那个时刻通过登录保存的,但当用户决定更改其电子邮件时,我必须更改此值Vb.net 如何撤销用户的令牌,vb.net,google-api,google-oauth,gmail-api,Vb.net,Google Api,Google Oauth,Gmail Api,如何为用户撤销令牌 这是我的身份验证代码,我想为一个用户重置(撤销)访问权限。这是因为我使用,我希望允许我的用户在必要时更改他们的电子邮件 实际上,令牌是在到达令牌的那个时刻通过登录保存的,但当用户决定更改其电子邮件时,我必须更改此值 Dim datafolder As String = Server.MapPath("App_Data/GoogleService.api.auth.store") Dim scopes As IList(Of String) = New List
Dim datafolder As String = Server.MapPath("App_Data/GoogleService.api.auth.store")
Dim scopes As IList(Of String) = New List(Of String)()
Dim UserId As String = Context.User.Identity.Name.ToString
scopes.Add(DriveService.Scope.Drive)
scopes.Add(GmailService.Scope.MailGoogleCom)
Dim myclientsecret As New ClientSecrets() With { _
.ClientId = CLIENT_ID, _
.ClientSecret = CLIENT_SECRET _
}
Dim flow As GoogleAuthorizationCodeFlow
flow = New GoogleAuthorizationCodeFlow(New GoogleAuthorizationCodeFlow.Initializer() With { _
.DataStore = New FileDataStore(datafolder), _
.ClientSecrets = myclientsecret, _
.Scopes = scopes _
})
Dim uri As String = Request.Url.ToString()
Dim code = Request("code")
If code IsNot Nothing Then
Dim token = flow.ExchangeCodeForTokenAsync(UserId, code, uri.Substring(0, uri.IndexOf("?")), CancellationToken.None).Result
' Extract the right state.
Dim oauthState = AuthWebUtility.ExtracRedirectFromState(flow.DataStore, UserId, Request("state")).Result
Response.Redirect(oauthState)
Else
Dim result = New AuthorizationCodeWebApp(flow, uri, uri).AuthorizeAsync(UserId, CancellationToken.None).Result
If result.RedirectUri IsNot Nothing Then
' Redirect the user to the authorization server.
Response.Redirect(result.RedirectUri)
Else
' The data store contains the user credential, so the user has been already authenticated.
myDriveService = New DriveService(New BaseClientService.Initializer() With { _
.ApplicationName = "Liens Google SyGED", _
.HttpClientInitializer = result.Credential _
})
myGMailService = New GmailService(New BaseClientService.Initializer() With { _
.ApplicationName = "Liens Google SyGED", _
.HttpClientInitializer = result.Credential _
})
End If
End If
您可以通过调用{token}来撤销令牌
阅读您是否尝试删除userid文件?我在服务器上找不到文件FileDataStore将文件存储在%appdata%中您在那里检查了吗?我在AppDataI中没有看到任何文件我最终找到了。谢谢