1
我正在創建一個谷歌驅動器設備應用程序。 ,我試圖去通過教程: https://developers.google.com/accounts/docs/OAuth2ForDevicesvb.net谷歌API的設備認證簡單的HTTP發佈請求失敗
和我上了弗里斯特股票步驟簡單的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不是正確的工具? 謝謝
問題是,這是一個有限的訪問應用程序設備的身份驗證網址必須在其他計算機上使用「http://www.google.com/device」完成,其中用戶鍵入他提供的代碼。 – Lambda