How do I get the current user's access token in AngularFire2?

后端 未结 7 2184
星月不相逢
星月不相逢 2021-02-08 11:10

In AngularFire you were able to access the providers (e.g Google) accessToken for the authenticated user.

There does not seem to be a way to access this with AngularFire

7条回答
  •  南方客
    南方客 (楼主)
    2021-02-08 11:29

    This works for me:

    this.af.auth.getAuth().auth.getToken(false);//true if you want to force token refresh
    

    You can put it into a Service and then you can get the token like this:

    this.authService.getToken().then(
      (token) => console.debug(`******** Token: ${token}`));
    

提交回复
热议问题