Home » Android » android – Create new ParseUser using Google+ AccessToken returns InvalidSession?

android – Create new ParseUser using Google+ AccessToken returns InvalidSession?

Posted by: admin May 14, 2020 Leave a comment

Questions:

I’m trying to create a new ParseUser using a Google+ SignIn. While I’m able to retrieve the access token successfully from Google, I get a ParseException(InvalidSession).
I’ll post a few snippets that are relevant.

This is how im getting the AccessToken from Google

final String SCOPES = "https://www.googleapis.com/auth/plus.login ";  
token = GoogleAuthUtil.getToken(
    MainActivity.this,
    Plus.AccountApi.getAccountName(mGoogleApiClient),
    "oauth2:" + SCOPES);

Making ParseUser

ParseUser.becomeInBackground(token, new LogInCallback()
{
    public void done(ParseUser user, ParseException e) 
    {
        Log.i(TAG, "makeParseUser"+"2");
        if (user != null)
        {
            // The current user is now set to user.
            /*
            user.put("name", s1);
            user.put("email",s6);
            user.saveInBackground();
            */
        }else 
        {
            // The token could not be validated.
            Log.i(TAG, "makeParseUser"+e.getLocalizedMessage());
        }
    }
});

A similar question has been asked here but there doesn’t seem to be a proper solution to it.

How to&Answers:

Currently Parse doesn’t support G+ login. Practically it can be done by using Parse cloud code.

ParseUser.becomeInBackground(); expects Parse User token, but not G+ one.