2016-08-17 85 views
0

所以,我試圖做一個程序,將爲我上傳視頻,所以我不必花這麼多時間,我已經拿出下面的代碼:Visual Basic訪問令牌Youtube API返回錯誤400

Imports System 
Imports System.Net 
Imports System.IO 
Module Module1 
    Sub Main() 
     Dim bytearray As String = "code=4/5tC9qk5APvWf_05GJRG-Ws5Ph4B1xXMZd0gw4iZEB50& 
client_id=349673303318-cp0upvjfcijukhnloppnpl5v57qkrr53.apps.googleusercontent.com& 
client_secret=s7gStNsZWua50Hlpot2XfSga& 
redirect_uri=https://localhost/oauth2callback& 
grant_type=authorization_code" 
     Dim request As WebRequest = WebRequest.Create("https://accounts.google.com/o/oauth2/token") 
     request.Credentials = CredentialCache.DefaultCredentials 
     request.Method = "POST" 
     request.ContentLength = bytearray.Length 
     request.ContentType = "application/x-www-form-urlencoded" 
     Dim dataStream As Stream = request.GetRequestStream() 
     dataStream.Write((Text.Encoding.UTF8.GetBytes(bytearray)), 0, bytearray.Length) 
     dataStream.Close() 
     Dim response As WebResponse = request.GetResponse() 
     My.Computer.Clipboard.SetText(Convert.ToString(response.GetResponseStream)) 
     response.Close() 
    End Sub 

End Module 

這是在Visual Basic中。

問題是,當我發送請求時,它從服務器返回錯誤400(錯誤請求)。

回答

相關問題