question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

setCredentials is required but not mentioned in documentation when using setServiceAccountId

See original GitHub issue
  • Library version: 6.6.0
  • Firebase Product: firebase-admin

Following the documentation under “Using a service account ID” I should be able to skip the setCredentials option in the builder, as based on the documentation it’s assumed to replace the need for a local copy of service-account.json. However should the setCredentials be missed, a NullPointerException is thrown

Caused by: java.lang.NullPointerException: FirebaseOptions must be initialized with setCredentials().

Attempt to set FirebaseOptions without a setCredentials option.

public FirebaseAuth firebaseAuth() throws IOException {
    FirebaseOptions options = new FirebaseOptions.Builder()
            .setServiceAccountId(SERVICE_ACCOUNT_EMAIL)
            .setProjectId(PROJECT_ID)
            .setDatabaseUrl(String.format("https://%s.firebaseio.com/", DATABASE_NAME))
            .build();

    FirebaseApp.initializeApp(options);

    return FirebaseAuth.getInstance();
}

Is the documentation incorrect/lacking detail or is this a bug?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
hiranya911commented, Feb 9, 2020

SDK always requires some credentials to authorize remote API calls. Service account ID is only used when signing JWTs using the Cloud IAM API (those API calls also need to be authorized with some credentials).

0reactions
ravindranathakilacommented, Feb 9, 2020

Thank you very much for clarifying. It gives a lot of confidence to know it won’t mess with all the users hooked up with Firebase (as in, doesn’t play a role in user session management). It would be unfortunate to later discover there were two keys linked to a token and one is gone thereby breaking all token validity.

On Sun, Feb 9, 2020, 9:04 AM Hiranya Jayathilaka notifications@github.com wrote:

SDK always requires some credentials to authorize remote API calls. Service account ID is only used when signing JWTs using the Cloud IAM API (those API calls also need to be authorized with some credentials).

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/firebase/firebase-admin-java/issues/234?email_source=notifications&email_token=AAJRF7F7EAJRXV7FVY6SZXLRB5JB3A5CNFSM4GMI5Y62YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOELF7T5A#issuecomment-583793140, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAJRF7A6MHXPEQYS4NCWBPTRB5JB3ANCNFSM4GMI5Y6Q .

Read more comments on GitHub >

github_iconTop Results From Across the Web

java - Providing Credentials to Google Cloud Storage API
For some background: I'm trying to compare and contrast Google Cloud Storage and Amazon S3. I can create a program like this in...
Read more >
Create Custom Tokens | Firebase Authentication - Google
You can create a custom token with the Firebase Admin SDK, or you can use a third-party JWT library if your server is...
Read more >
Class GoogleCredential (2.1.1) | Java client library
Thread-safe Google-specific implementation of the OAuth 2.0 helper for accessing protected resources using an access token, as well as optionally refreshing the ...
Read more >
Set up AWS Credentials and Region for Development
This topic provides basic information about setting up your AWS credentials for local application development using the AWS SDK for Java. If you...
Read more >
CON12 RADV Intake Process and Guidance to Coders - CMS
It is for internal government use only and must not be ... records for the validation of risk adjustment data, as required by...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found