Skip to content
This repository was archived by the owner on Apr 4, 2023. It is now read-only.

Commit b5c0d14

Browse files
There is no "getIdToken" method on firebase.auth().currentUser? #1189
1 parent e06f8db commit b5c0d14

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

docs/AUTHENTICATION.md

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -645,11 +645,15 @@ To solve, you will want to pass in the appropriate iOS controller of the active
645645
2. Google Sign-In requires an SHA1 fingerprint: see [Authenticating Your Client for details](https://developers.google.com/android/guides/client-auth). If you don't do this you will see the account selection popup, but you won't be able to actually sign in.
646646
3. Those fingerprints need to be added to your Firebase console. Go to 'project overview', 'project settings', then scroll down a bit.
647647

648-
### getAuthToken
648+
### getAuthToken / getIdToken
649649
If you want to authenticate your user from your backend server you can obtain a Firebase auth token for the currently logged in user.
650650

651651
You'll get the token, as well as the provider that was used to sign in, and any custom claims you may have previously set via the Firebase Admin SDK as outlined [here](https://firebase.google.com/docs/auth/admin/custom-claims):
652652

653+
654+
<details>
655+
<summary>Native API</summary>
656+
653657
```js
654658
firebase.getAuthToken({
655659
// default false, not recommended to set to true by Firebase but exposed for {N} devs nonetheless :)
@@ -666,6 +670,17 @@ You'll get the token, as well as the provider that was used to sign in, and any
666670
}
667671
);
668672
```
673+
</details>
674+
675+
<details>
676+
<summary>Web API</summary>
677+
678+
```typescript
679+
firebaseWebApi.auth().currentUser.getIdToken(false)
680+
.then((token: string) => console.log("Auth token retrieved: " + token))
681+
.catch(errorMessage => console.log("Auth token retrieval error: " + errorMessage));
682+
```
683+
</details>
669684

670685
### logout
671686
Shouldn't be more complicated than:
@@ -788,4 +803,4 @@ const firebaseWebApi = require("nativescript-plugin-firebase/app");
788803
const user = firebaseWebApi.auth().currentUser;
789804

790805
user.sendEmailVerification() // see the implementation above
791-
```
806+
```

0 commit comments

Comments
 (0)