8
I am using the followin code to get an Access Token, after connecting to Google+, to get profile info and e-mail:
String sAccessToken = GoogleAuthUtil.getToken(this,mPlusClient.getAccountName() + "",
"oauth2:" + Scopes.PLUS_PROFILE + "
https://www.googleapis.com/auth/userinfo.profile
https://www.googleapis.com/auth/userinfo.email");
This Access Token I am not storing and trying to re-use. Instead I ask for an Access Token everytime, expecting a new(different) Token, so that I don't need to check whether its expired etc..
But I am getting the same Access Token every time I ask for. I uninstalled the app, cleared data of Google+ App and still I get the same Access Token.
The Actual problem is, using this Access Token gives a 401 error - "message": "Invalid Credentials"
{
"error": {
"errors": [
{
"domain": "global",
"reason": "authError",
"message": "Invalid Credentials",
"locationType": "header",
"location": "Authorization"
}
],
"code": 401,
"message": "Invalid Credentials"
}
}
This is a response on browser.
On a device I get this in Logcat:
02-25 02:09:46.919: W/System.err(3022): java.io.FileNotFoundException: https://www.googleapis.com/oauth2/v1/userinfo
02-25 02:09:46.929: W/System.err(3022): at org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnectionImpl.getInputStream(HttpURLConnectionImpl.java:521)
02-25 02:09:46.929: W/System.err(3022): at org.apache.harmony.luni.internal.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:258)
02-25 02:09:46.929: W/System.err(3022): at com.example.gmaillogin.MainActivity$connectAsyncTask.doInBackground(MainActivity.java:269)
02-25 02:09:46.929: W/System.err(3022): at com.example.gmaillogin.MainActivity$conn