大佬教程收集整理的这篇文章主要介绍了vb.net – Google OAuth令牌错误 – 400错误请求,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
Public Sub New() Dim tokenRequest As WebRequest = WebRequest.Create("https://accounts.google.com/o/oauth2/token") Dim requestString As String = "code=<auth-code>" _ & "&client_id=<client_id>" _ & "&client_secret=<client_secret>" _ & "&redirect_uri=http://localhost" _ & "&grant_type=authorization_code" byteArray = StrToByteArray(System.Web.HttpUtility.UrlEncode(requestString)) tokenRequest.Credentials = CredentialCache.DefaultCredentials tokenRequest.Method = "POST" tokenRequest.ContentLength = byteArray.Length tokenRequest.ContentType = "application/x-www-form-urlencoded" Dim dataStream As Stream = tokenRequest.GetRequestStream() dataStream.Write(byteArray,byteArray.Length) dataStream.Close() Console.WriteLine("Getting response...") 'Get response Try Dim response As WebResponse = tokenRequest.GetResponse() Console.WriteLine(CType(response,HttpWebResponse).StatusDescription) Dim data As Stream = response.GetResponseStream Array.Resize(byteArray,4096) Array.Clear(byteArray,byteArray.Length) data.Read(byteArray,byteArray.Length) response.Close() Catch wex As WebException Console.WriteLine("ERROR! : ") Console.WriteLine(wex.Message) Console.WriteLine(wex.Status) Console.WriteLine(wex.Data) Console.WriteLine(wex.InnerException.Message) Console.WriteLine(wex.HelpLink) End Try End Sub
错误的具体情况如下:
The remote server returned an error: (400) Bad Request. 7 System.Collections.ListDictionaryInternal System.NullReferenceException: Object reference not set to an instance of an obj ect. at GADownload.GoogleAnalytics..ctor() in ***.vb:line 86 at GADownload.Main1.Main(String[] args) in ****.vb:line 18
我已经看过Google GetAccessToken : Bad Request 400和Google GData .Net OAuthUtil.GetAccessToken 400 Bad Request,但还没有找到适合此代码的解决方案.我已经检查了所有建议的解决方案并实施了它们,但到目前为止还没有运气.
您可以使用curl命令调试这些参数,以查看这是否是问题的根源.例如
curl -X POST -d "code=<auth-code>&client_id=<client_id>&client_secret=<client_secret>"&grant_type=authorization_code" http://localhost:8000/auth/token
以上是大佬教程为你收集整理的vb.net – Google OAuth令牌错误 – 400错误请求全部内容,希望文章能够帮你解决vb.net – Google OAuth令牌错误 – 400错误请求所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。