0
votes

I'm picking up a project from last year that was based on the now discontinued 'mobile backend starter' from Google. I believe the app was left in a working state but it now seems to fail the authentication when the "Secured by Client IDs" setting is selected on the web page google provided. I get the following error:

com.google.api.client.googleapis.json.GoogleJsonResponseException: 401 Unauthorized
{
"code": 401,
"errors": [
{
"domain": "global",
"location": "Authorization",
"locationType": "header",
"message": "Unauthenticated calls are not allowed",
"reason": "required"
}
],
"message": "Unauthenticated calls are not allowed"
}

The error results from running this method

private void listPosts(final String alertTxt) {
    // create a response handler that will receive the result or an error
    CloudCallbackHandler<List<CloudEntity>> handler =
            new CloudCallbackHandler<List<CloudEntity>>() {
                @Override
                public void onComplete(List<CloudEntity> results) {
                    //mAnnounceTxt.setText(R.string.announce_success);
                    mAnnounceTxt.setText(alertTxt);
                    mPosts = results;
                    animateArrival();
                    updateGuestbookView();
                }

                @Override
                public void onError(IOException exception) {
                    mAnnounceTxt.setText(R.string.announce_fail);
                    animateArrival();
                    handleEndpointException(exception);
                }
            };
...

I am not really sure where/how to start debugging this?

1
Did you manage to get this running? Does it still work? - keithmaxx

1 Answers

0
votes

401 Errors are usually caused by any of the following:

  • Expired token
  • Token revocation
  • Token not authorized for needed scopes
  • Request not authorized correctly with OAuth

Try refreshToken() to resolve expired token issues