Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

get Firebase Access token (oAuth2) #882

Open
waleedmakarem opened this issue Sep 27, 2024 · 0 comments
Open

get Firebase Access token (oAuth2) #882

waleedmakarem opened this issue Sep 27, 2024 · 0 comments
Labels
bug triage Issues that need to be triaged

Comments

@waleedmakarem
Copy link

Can i use the library to get Firebase Access token (oAuth2) . I have firebase ServiceAccount json data. below is my running java code that works using

private static final String firebaseMessagingScope = "https://www.googleapis.com/auth/firebase.messaging";

public void getAccessTokenfromFile(Context mcontext, AccessTokenCallback callback) {
    new Thread(new Runnable() {
        @Override
        public void run() {
            try {
                InputStream stream = mcontext.getAssets().open("serviceaccount.json");
                GoogleCredentials googleCredentials = GoogleCredentials.fromStream(stream).createScoped(firebaseMessagingScope);
                googleCredentials.refresh();
                final String token = googleCredentials.getAccessToken().getTokenValue();
                // Handle the token here
                callback.onAccessTokenReceived();
            } catch (Exception e) {
                callback.onAccessTokenError(e.getMessage());
            }
        }
    }).start();

}

my service account file as below data headers:

<title></title> <style type="text/css"> p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 13.0px '.AppleSystemUIFont'} table.t1 {border-collapse: collapse} td.td1 {border-style: solid; border-width: 1.0px 1.0px 1.0px 1.0px; border-color: #9a9a9a #9a9a9a #9a9a9a #9a9a9a; padding: 1.0px 5.0px 1.0px 5.0px} </style>

type

project_id
private_key_id
private_key
client_email
client_id
auth_uri
token_uri
auth_provider_x509_cert_url
client_x509_cert_url
universe_domain

@waleedmakarem waleedmakarem added bug triage Issues that need to be triaged labels Sep 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug triage Issues that need to be triaged
Projects
None yet
Development

No branches or pull requests

1 participant