I finally found a solution. Use of the tutorial found here .
You must add the client ID in GoogleSignInOptions:
GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN) .requestIdToken(CLIENT_ID) .requestEmail() .build();
Following the tutorial, you will finally get a GoogleSignInAccount. Set the token from the GoogleSignInAccount in the GoogleCredential object:
GoogleCredential credential = new GoogleCredential.Builder().setTransport(new NetHttpTransport()) .setJsonFactory(JacksonFactory.getDefaultInstance()) .build(); credential.setAccessToken(GoogleSignInAccount.getIdToken());
These credentials are ready to make authenticated calls to Google Cloud Enpoints.
Note that you must remove the "server: client_id:" part from the identifier CLIENT_ID. Therefore, if you used this:
credential = GoogleAccountCredential.usingAudience(this, "server:client_id:1-web-app.apps.googleusercontent.com");
Your CLIENT_ID will be:
CLIENT_ID = "1-web-app.apps.googleusercontent.com"
Also note that the token is valid for a limited period of time (Aprox. 1 hour in my testing)
source share