Я пытаюсь обменять код авторизации на токен и все время получаю «redirect_uri_mismatch». Теперь все URL, которые написаны в консоли идентичны REDIRECT_URL, что я посылаю в теле веб-запроса POST,Веб-приложение Google Oauth2 redirect_uri_mismatch
это код (VB) после получения ответа с кодом авторизовать:
Dim strCode As String = HttpContext.Current.Request.QueryString("code")
Dim getTokenBody As String
getTokenBody = "code=" & HttpContext.Current.Server.UrlEncode(strCode) & _
"&client_id=" & HttpContext.Current.Server.UrlEncode(AppStaticData.Config.GoogleClientID.Value) & _
"&client_secret=" & HttpContext.Current.Server.UrlEncode(AppStaticData.Config.GoogleClientSecret.Value) & _
"&redirect_uri=" & HttpContext.Current.Server.UrlEncode("http://localhost:53706/user/authenticate") & _
"&scope=" & _
"&grant_type=authorization_code"
Dim buffer As Byte() = Encoding.ASCII.GetBytes(getTokenBody)
Dim url = "https://accounts.google.com/o/oauth2/token"
Dim request As HttpWebRequest = WebRequest.Create(url)
request.Method = "POST"
request.ContentType = "application/x-www-form-urlencoded"
request.ContentLength = buffer.Length
Dim strm As Stream = request.GetRequestStream()
strm.Write(buffer, 0, buffer.Length)
strm.Close()
Try
Dim res As HttpWebResponse = request.GetResponse()
Catch ex As WebException
Dim a = ex.Response
Dim wr As Net.HttpWebResponse = DirectCast(a, Net.HttpWebResponse)
Dim s = New StreamReader(wr.GetResponseStream()).ReadToEnd
End Try
Является ли URL в надежном списке для вашего приложения? –
@the_lotus да это – ishigh