c# - Picasa ClientLogin deprecation issues -
i have been using picasa client login couple of years without issue. use store photos users upload not want request user authentication storing photos in our own account. developed in .net.
up until today has worked , can’t work out (and beginning wander whether possible) how fix issue.
previous code:
picasaservice service = new picasaservice("my app"); service.setusercredentials("myemail@gmail.com", "password"); uri posturi = new uri(picasaquery.createpicasauri("default", albumid)); string scontenttype = "image/jpeg"; picasaentry entry = (picasaentry)service.insert(posturi, filestream, scontenttype, sfilename); filestream.close(); spicasaurl = entry.media.content.url.tostring();
new code using auth2 (that doesn’t work!) - have gone onto developer console , set client id. using p12 key in application generated there access code.
uri posturi = new uri(picasaquery.createpicasauri("default", albumid)); const string serviceaccountemail = "email@developer.gserviceaccount.com"; var certificate = new x509certificate2(httpcontext.current.server.mappath("bin/key2.p12"), "notasecret", x509keystorageflags.exportable); var serviceaccountcredentialinitializer = new serviceaccountcredential.initializer(serviceaccountemail) { scopes = new[] { "https://picasaweb.google.com/data/" } }.fromcertificate(certificate); var credential = new serviceaccountcredential(serviceaccountcredentialinitializer); if(!credential.requestaccesstokenasync(system.threading.cancellationtoken.none).result) throw new invalidoperationexception("access token request failed."); var requestfactory = new gdatarequestfactory(null); requestfactory.customheaders.add("authorization: bearer " + credential.token.accesstoken); picasaservice service = new picasaservice("my app"); service.requestfactory = requestfactory; string scontenttype = "image/jpeg"; picasaentry entry = (picasaentry)service.insert(posturi, filestream, scontenttype, sfilename); filestream.close(); spicasaurl = entry.media.content.url.tostring();
can help?
i :
"the remote server returned error: (404) not found." error.
{"execution of request failed: https://picasaweb.google.com/data/feed/api/user/default/albumid/myalbumid"}
is type of login possible clientlogin deprecated?
thanks in advance!
you need check new oauth2 authentication protocol google enabled 2 days ago.
the clientlogin api deprecated , not work anymore...
i working on solving same issue , post sample java code comments soon.
cheers, gizmo
Comments
Post a Comment