Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angularjs angularfire使用之前发布的firebase令牌登录_Angularjs_Angularfire - Fatal编程技术网

Angularjs angularfire使用之前发布的firebase令牌登录

Angularjs angularfire使用之前发布的firebase令牌登录,angularjs,angularfire,Angularjs,Angularfire,我正在使用一个单独的服务器来验证我的angular应用程序。作为该过程的一部分,服务器已经使用firebase对用户进行了身份验证,并收到了一个身份验证令牌。angular应用程序提供后,我从服务器重新请求令牌,现在我想发出angularFireAuth.login() 我尝试过这个,但得到了一个“引用错误无法识别的身份”。我是否遗漏了一些非常基本的东西?难道我不能使用预先存在的firebase身份验证令牌登录吗 代码如下: var profileController = functio

我正在使用一个单独的服务器来验证我的angular应用程序。作为该过程的一部分,服务器已经使用firebase对用户进行了身份验证,并收到了一个身份验证令牌。angular应用程序提供后,我从服务器重新请求令牌,现在我想发出angularFireAuth.login()

我尝试过这个,但得到了一个“引用错误无法识别的身份”。我是否遗漏了一些非常基本的东西?难道我不能使用预先存在的firebase身份验证令牌登录吗

代码如下:

    var profileController = function ($rootScope, $scope, $log, $location, angularFire, angularFireAuth, profileService) {
    init();

    function init() {
        $scope.profile = {};

        profileService.getFirebaseToken(function success(data) {
                $scope.auths = data;$
                $scope.auth = $rootScope.auth;
                var id = {'id': data['_id']};
                auth=angularFireAuth.login(data['access_token'],id);
                $scope.auth = auth;
            }, function error(err) {
            console.log('error', err);
        });
**注意:data[''u id']=字符串id,它是firebase中的用户id,在我的安全规则中用作auth.id
数据['access_token']=字符串标记。这不是字典或对象。仅返回以下字符串标记:token=create_token(机密、自定义_数据、选项)。它使用:firebase\u token\u生成器模块在我的python tornado服务器上成功运行。

确定。我想出来了。我收到的错误是因为登录请求是异步的。所以“Reference Error:auth”是因为变量auth在赋值之前被引用了。 我最终没有使用上面的代码。因此,我不知道这是否有效。相反,我切换到firebase站点上的构造:

   fbLoginService.getFirebaseToken(function success(data) {
        var dataRef = new Firebase('xxxxxx.firebaseio.com')
        dataRef.auth(data['firebase']['access_token'], function(error) {
          if(error) {
            console.log("Login Failed!", error);
            alert("Login Failure.  Unable to login to database(firebase)");
          } else {
            console.log("Firebase Login Succeeded!");
            $rootScope.firebaseAuth=true;
          }
        });
    }, function error(err) {
        console.log('error', err);
        alert('error', err);
    });

现在,我已经创建了一个loginController和loginService,在初始加载index.html时启动它,并包含ng controller=“fbLoginController”。到目前为止,一切看起来都不错。

请将您的示例验证代码添加到JSFIDLE。可能您没有完全配置firebase auth帐户或应用程序。在创建fiddle之前,请让我发布代码: