热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

类型“AuthCredential”上不存在属性“accessToken”

如何解决《类型“AuthCredential”上不存在属性“accessToken”》经验,为你挑选了1个好方法。

通过运行离子服务,我得到以下错误:

Property 'accessToken' does not exist on type 'AuthCredential'.
// You can use it to access the Google API.
let token = result.credential.accessToken;

我的火力基地已从更新firebase: ^4.12.1firebase: ^5.5.9

这是我的离子信息输出

Ionic:

   ionic (Ionic CLI)  : 4.1.2
   Ionic Framework    : ionic-angular 3.9.2
   @ionic/app-scripts : 3.1.9

Cordova:

   cordova (Cordova CLI) : 8.1.2 (cordova-lib@8.1.1)
   Cordova Platforms     : android 7.0.0
   Cordova Plugins       : no whitelisted plugins (19 plugins total)

System:

   NodeJS : v10.13.0 (C:\Program Files\nodejs\node.exe)
   npm    : 5.8.0
   OS     : Windows 10

这是 auth.service.ts

signInWithGoogle() {
   console.log('Sign in with google');
   return this.oauthSignIn(new firebase.auth.GoogleAuthProvider());
}

private oauthSignIn(provider: AuthProvider) {
   if (!(window).cordova) {
        return this.afAuth.auth.signInWithPopup(provider).then(() => {
            this.saveUserDetails('gmail');
        });
   } else {
       return this.afAuth.auth.signInWithRedirect(provider)
           .then(() => {
              return this.afAuth.auth.getRedirectResult().then(result => {
                 // This gives you a Google Access Token.
                // You can use it to access the Google API.
                let token = result.credential.accessToken;
               // The signed-in user info.
                let result_user = result.user;

                this.saveUserDetails('gmail');

                console.log(token, result_user);
      }).catch(function (error) {
         // Handle Errors here.
         alert(error.message);
      });
   });
  }
}

为什么AuthCredential对象上不存在accessToken属性?



1> bojeil..:

你需要转换AuthCredentialOAuthCredential具有的accessToken特性:https://github.com/firebase/firebase-js-sdk/blob/master/packages/auth-types/index.d.ts#L244


推荐阅读
author-avatar
林yong珊_450
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有