【发布时间】:2014-07-19 13:55:14
【问题描述】:
我正在寻找使用 Asp.Net 的 Owin OAuth 库对 Google 的 api 进行增量授权的解决方案。
我知道如何为特定 api 设置范围,但我想逐步进行,只能看到如何在全局范围内设置。
关于 Google Oauth 增量身份验证的文档... https://developers.google.com/accounts/docs/OAuth2WebServer#incrementalAuth
当前的 VB 代码...
Public Sub ConfigureAuth(app As IAppBuilder)
Dim googleCreds = New GoogleOAuth2AuthenticationOptions() With {
.ClientId = "xxxx",
.ClientSecret = "xxx"
}
googleCreds.Scope.Add("https://www.googleapis.com/auth/analytics.readonly")
app.UseGoogleAuthentication(googleCreds)
' Would like to add another way to specify GoogleDrive, YouTube, Google+ scopes
' Example code that doesn't work that would add a 2nd Google Oauth Listener
googleCreds.Scope.Clear()
googleCreds.Scope.Add("https://www.googleapis.com/auth/drive.file")
googleCreds.AuthenticationType = "GoogleDrive"
app.UseGoogleAuthentication(googleCreds)
End Class
【问题讨论】:
-
好问题!我一直在动态设置 OWIN 范围、每个 Web 请求的 OWIN OAuth 范围、更改 OWIN OAuth 范围……应该支持开箱即用的 IMO,因为所有提供商似乎都鼓励它。
标签: asp.net oauth google-oauth owin