oauth 2.0 - Right credentials in requestBody for Android Google Play Oauth2 gtalk authToken -
running code below "error" : "unauthorized_client". need pinpoint have done wrong. want use in android app enable google talk (xmpp there xabber fork)
reading much how , come google api console setup.
have chosen
- client id installed applications
- installed application type = other
- enabled google play android developer api (green switch)
i authentication token oauth2:https://www.googleapis.com/auth/googletalk. (user approval screen) bugs me dont enter sha1 fingerprint or package name "other" maybe that's problem
code:
httpclient client1 = new defaulthttpclient(); httppost request1 = new httppost("https://accounts.google.com/o/oauth2/token" ); request1.setheader("content-type", "application/x-www-form-urlencoded"); //please make custom you're credentials string requestbody1 = "code="+authtoken+ "&client_id=749825062016ia.apps.googleusercontent.com"+ "&client_secret=jq1nurayuibuf6hn5pwpe" + "&redirect_uri=urn:ietf:wg:oauth:2.0:oob" + "&grant_type=authorization_code"; try { request1.setentity(new stringentity(requestbody1)); } catch (unsupportedencodingexception e) { e.printstacktrace(); } /* checking response */ try { httpresponse response = client1.execute(request1); string results = "error"; results = entityutils.tostring(response.getentity()); logmanager.i("stack", "response::" + results); } catch (ioexception e) { e.printstacktrace(); }
i think should have registered application type 'android'. asked provide information (such package name , certificate) allow android platform recognize application.
Comments
Post a Comment