mithil1501
mithil1501

Reputation: 526

unable to regenerate Uber Access Token using Uber Refresh Token on Server side

For Uber login, I am following 'Single Sign On' login mechanism on Android Phone side, but I am facing a problem due to refresh token. The refresh token (of 30 char count) which we get in AccessToken class we pass it on to Server to refresh the access token. However Server is unable to regenerate the access token with this refresh token using :

curl -F 'client_secret=CLIENT-SERCRET' \
     -F 'client_id=CLIENT_ID' \
     -F 'grant_type=refresh_token' \
     -F 'refresh_token=REFRESH_TOKEN_FROM_ANDROID' \
      https://login.uber.com/oauth/v2/token

and getting error:

{"error": "invalid_grant"}

The access token is required to get rides related details on server side.

We are stuck with this issue and any help would be appreciated. Thanks in advance.

Following is the code snippet for Login callback from which we get refresh token:

private class UberLoginCallback implements LoginCallback {

    @Override
    public void onLoginCancel() {
    }

    @Override
    public void onLoginError(@NonNull AuthenticationError error) {
    }

    @Override
    public void onLoginSuccess(@NonNull AccessToken accessToken) {
        String accessToken = accessToken.getToken()
        String refreshToekn = accessToken.getRefreshToken()
        /*Passing this refresh token on server side but doesn't work as expected*/ 
    }

    @Override
    public void onAuthorizationCodeReceived(@NonNull String authorizationCode) {
        Log.d(TAG, "Authorization Code : " + authorizationCode);
    }
}

Upvotes: 1

Views: 238

Answers (1)

Sasa Jovanovic
Sasa Jovanovic

Reputation: 857

If you get {"error": "invalid_grant"} when trying to get new access_token this means the refresh token being used is expired or has become invalid. Related to your case where you try to get refresh token from onLoginSuccess method - there is currently a problem with the AccessToken object - because AccessToken has one empty refresh token parameter. We're currently working on resolving that issue.

Upvotes: 2

Related Questions