I'm using firebase.auth().signInWithEmailAndPassword(email, password) to sign into my App. I want to retrieve "accessToken" from "stsTokenManager" Object. How can I get it? Following is the response from above line of code:
Object {
"apiKey": "",
"appName": "[DEFAULT]",
"authDomain": "myApp-5e47b.firebaseapp.com",
"createdAt": "1589567878396",
"displayName": "TestFirstName",
"email": "test@gmail.com",
"emailVerified": false,
"isAnonymous": false,
"lastLoginAt": "1589617057893",
"phoneNumber": null,
"photoURL": null,
"providerData": Array [
Object {
"displayName": "TestFirstName",
"email": "test@gmail.com",
"phoneNumber": null,
"photoURL": null,
"providerId": "password",
"uid": "test@gmail.com",
},
],
"redirectEventId": null,
"stsTokenManager": Object {
"accessToken": "",
"apiKey": "",
"expirationTime": 1589620681845,
"refreshToken": "",
},
"tenantId": null,
"uid": "",
}
You can get user access token by following snippet
const token = await firebase.auth().currentUser.getIdToken();
To force refresh token
const token = await firebase.auth().currentUser.getIdToken(true);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.