Dim p_service As Google.GData.Client.Service = New Google.GData.Photos.PicasaService("Auth_test_app")
Dim p_parameters As New Google.GData.Client.OAuth2Parameters()
Dim p_application_name As String = "test_app"
'STEP 1 - configure how to use OAuth 2.0
Dim CLIENT_ID As String = "xxxxxxx.apps.googleusercontent.com"
Dim CLIENT_SECRET As String = "xxxxxx"
Dim SCOPE As String = "http://picasaweb.google.com/data/"
Dim REDIRECT_URI As String = "xxxxx:2.0:oob"
'STEP 2 - set up the OAuth 2.0 object
p_parameters.ClientId = CLIENT_ID
p_parameters.ClientSecret = CLIENT_SECRET
p_parameters.RedirectUri = REDIRECT_URI
p_parameters.Scope = SCOPE
'STEP 3 - get the authorization url
Dim authorizationUrl As String = Google.GData.Client.OAuthUtil.CreateOAuth2AuthorizationUrl(p_parameters)
'I have my access token with :) Process.Start(authorizationUrl)
p_parameters.AccessToken = "xxx"
Dim requestFactory As New Google.GData.Client.GOAuth2RequestFactory(Nothing, p_application_name, p_parameters)
p_service.RequestFactory = requestFactory 'once set we dont need to do OAuth until expires
'ERROR HERE!!!!!!!!!
dim user_id ="104929871952334xxxxx"
dim album_id ="60664808827372xxxxx"
Dim postUri As New Uri(PicasaQuery.CreatePicasaUri(user_id, album_id))
'My image url :)
Dim fileInfo As New System.IO.FileInfo("C:\Users\1.jpg")
Dim fileStream As System.IO.FileStream = fileInfo.OpenRead()
'NOW ERROR
Dim request = p_service.Insert(postUri, fileStream, "image/bmp", "Name Image.")
执行计划。
执行请求失败:https://picasaweb.google.com/data/feed/api/user/104929871952334xxxxx/albumid/60664808827372xxxxx
我有这个错误,请不要将图片上传到piccasa。
答案 0 :(得分:0)
我认为您错过了此应用的权限:" https://picasaweb.google.com/data/ 代码:
string[] scopes = new string[] {"https://picasaweb.google.com/data/", Oauth2Service.Scope.UserinfoEmail };