I'm using Firebase authentication together with Cloud Endpoints Frameworks. In context of this, I have two questions which belong together:
In my Android app I'm requesting the access token after a successfully login in the following way:
FirebaseUser user = mFirebaseAuthenticator.getCurrentUser();
user.getIdToken(true).addOnCompleteListener(new OnCompleteListener<GetTokenResult>() {
public void onComplete(@NonNull Task<GetTokenResult> task) {
if (task.isSuccessful()) {
mIDToken = task.getResult().getToken();
Log.d("attempLogin", "GetTokenResult result = " + mIDToken);
} else {
Log.d("attempLogin", "Cannot get token = " + task.getException());
}
}
});
Afterwards I pass the received access token to the automatically generated endpoints framework client API method allOrdersRequest(...)
OrderCollection orders = allOrdersRequest.setOauthToken(mIDToken).execute();
to execute a valid and authorized backend API call.
1st question: The received access token has about 800 characters, which is in my opinion relatively too much. It's almost 1kb which has to be send with each backend API method request. Is my assumption correct, or should (or even can I) change the access token size in Firebase's console?
2nd question: Is it the right way to pass the received token to the setOauthToken() method of the endpoints framework client API to perform an authorized API request, or must I manipulate each time the httpheader of the allOrdersRequest()?