[英]httpsrequest google drive refreshtoken
我正在嘗試創建一個http請求,以使用存儲的refreshtoken獲取一個新的accesstoken,以便可以訪問Google雲端硬盤。
Dim uri As String = "https://accounts.google.com/o/oauth2/token"
Dim para As String = "code='" + cred.RefreshToken + "'&client_id='" + ClientCredentials.CLIENT_ID + "'&client_secret='" + ClientCredentials.CLIENT_SECRET + "'&grant_type='refresh_token'"
Dim httpWebRequest As System.Net.HttpWebRequest = Net.WebRequest.Create(uri)
httpWebRequest.Method = "POST"
httpWebRequest.ContentType = "application/x-www-form-urlencoded"
Dim requestStream As System.IO.Stream = httpWebRequest.GetRequestStream()
Dim streamwriter As System.IO.StreamWriter = New System.IO.StreamWriter(requestStream)
streamwriter.Write(para)
streamwriter.Close()
Dim httpWebResponse As System.Net.HttpWebResponse = httpWebRequest.GetResponse()
但這返回了一個錯誤的請求。 我錯過了什么?
您沒有將憑據寫入StreamWriter,它應顯示為...
streamwriter.Write(para)
那當然是假設它們是正確的。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.