OAuth2를 사용하고 '설치된 애플리케이션'흐름 (인증 코드 및 토큰 요청)을 사용하여 애플리케이션을 인증하려고합니다. GetResponse() 줄에서 토큰을 요청할 때 400 bad request error
이 표시됩니다. 오류의Google OAuth Token 오류 - 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, 0, 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, 0, byteArray.Length)
data.Read(byteArray, 0, 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를 살펴 했어하지만이 코드에 적합한 해결책을 발견하지 않은 다음과 같이 내 코드는 . 이미 제안 된 모든 솔루션을 확인하고 구현했지만 지금까지는 운이 없었습니다. 당신이 매개 변수 인증 코드 값을 설정하지 않는 것 같은