Skip to content Skip to sidebar Skip to footer

Android: Firebase Auth For Cloud End Point Not Working

I have followed the link and have done the configuration on the server as mentioned. '/users': post: description: '' operationId: '' pro

Solution 1:

After so many days of struggle I am able to solve the issue.

I solved the issue by following this,

    "/users":
post:
  description: "<Description>"
  operationId: "<OperationID>"
  produces:
  - "application/json"
  responses:
    200:
      description: "user List"
      schema:
        $ref: "#/definitions/echoMessage"
  parameters:
  - description: "Search Criteria"
    in: body
    name: message
    required: true
    schema:
      $ref: "#/definitions/echoMessage"
  security:
    - firebase: []

and

firebase:
authorizationUrl: ""
flow: "implicit"
type: "oauth2"
x-google-issuer: "https://securetoken.google.com/<Project-ID>"
x-google-jwks_uri: "https://www.googleapis.com/service_accounts/v1/metadata/x509/securetoken@system.gserviceaccount.com"
x-google-audiences: "<Project-ID>" //I have added this, this was the main culprit.

as mentioned in the comment, I was missing

x-google-audiences: ""

in the server configuration.

And for another clarification for which token to use: We have to use the second approach that I have mentioned in the question, i.e, as below,

FirebaseUser firebaseUser = FirebaseAuth.getInstance().getCurrentUser();
    if (firebaseUser != null) { 

        firebaseUser.getIdToken(true)
                .addOnSuccessListener(new OnSuccessListener<GetTokenResult>() { 
                    @Override 
                    public void onSuccess(GetTokenResult getTokenResult) {
                        String token = getTokenResult.getToken();
                        SharedPreferences.Editor editor = mSharedPreferences.edit();
                        editor.putString(Constants.PREFS_FCM_TOKEN, token);
                        editor.apply();
                    } 
                }); 
    }

Post a Comment for "Android: Firebase Auth For Cloud End Point Not Working"