我正在尝试开始处理谷歌oauth2
我的应用程序将被称为服务器应用程序。它应该在没有用户输入的情况下工作。到目前为止我的代码(仅尝试获取访问令牌):
Dim strToken = Request.QueryString("code")
Dim strExchange = "response_type=code"
strExchange += "&redirect_uri=http://xxxx.zzzzz.com/test/google.aspx"
strExchange += "&client_id=xxxx7hju.apps.googleusercontent.com"
strExchange += "&scope=&"
strExchange += "client_secret=yJpGI1yQBCvvxxxxx&grant_type=authorization_code"
Dim url = "https://accounts.google.com/o/oauth2/auth?"
Dim webClient As New System.Net.WebClient
Dim result As String = webClient.DownloadString(url & strExchange)
Response.Write(result)
这给了我不好的请求(400)
答案 0 :(得分:0)
您可以尝试处理Google日历条目的Article。他们能够获得oauth2.0认证技术的适当文档。希望所有的值都来自App.Config
clientId = ConfigurationManager.AppSettings("client_id").ToString
clientSecret = ConfigurationManager.AppSettings("client_secret").ToString
redirecturi = ConfigurationManager.AppSettings("redirect").ToString
mainUser = ConfigurationManager.AppSettings("mainuser").ToString
Public Sub authorize()
Dim Uri As String = "https://accounts.google.com/o/oauth2/auth?access_type=offline&response_type=code&client_id=" & clientId & "&redirect_uri=" & redirecturi & "&scope=https://www.googleapis.com/auth/calendar&login_hint=" & mainUser & "&include_granted_scopes=true"
Response.Redirect(Uri)
End Sub