我正在创建一个谷歌驱动设备应用程序。我正在尝试阅读本教程: https ://developers.google.com/accounts/docs/OAuth2ForDevices
我第一时间就有货了 简单的 POST 步骤
这返回 400 错误请求:
Try
Dim request As HttpWebRequest
Dim response As HttpWebResponse = Nothing
Dim reader As StreamReader
Dim data As StringBuilder
Dim byteData() As Byte
Dim postStream As Stream = Nothing
request = DirectCast(WebRequest.Create("https://accounts.google.com/o/oauth2/device/code"), HttpWebRequest)
request.Method = "POST"
request.ContentType = "application/x-www-form-urlencoded"
data = New StringBuilder()
data.Append("client_id=XXXXXXXXXXX.apps.googleusercontent.com&")
data.Append("scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fdrive")
byteData = UTF8Encoding.UTF8.GetBytes(data.ToString())
request.ContentLength = byteData.Length
Try
postStream = request.GetRequestStream()
postStream.Write(byteData, 0, byteData.Length)
Finally
If Not postStream Is Nothing Then postStream.Close()
End Try
Try
' Get response
response = DirectCast(request.GetResponse(), HttpWebResponse)
' Get the response stream into a reader
reader = New StreamReader(response.GetResponseStream())
' Console application output
tb1.Text = reader.ReadToEnd()
Finally
If Not response Is Nothing Then response.Close()
End Try
Catch ex As Exception
tb1.Text = ex.Message
End Try
我缺少发布信息吗?是 httpwebrequest 不是正确的工具吗?谢谢