Google ドライブ デバイス アプリケーションを作成しています。そして、チュートリアルを実行しようとしています: https://developers.google.com/accounts/docs/OAuth2ForDevices
そして私は最初に在庫を手に入れましたシンプルなポストを踏む
これは 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 は適切なツールではありませんか? ありがとう