1
votes

I can't able to access the firebase. Error log shows:

Projects created at console.firebase.google.com must use the new Firebase Authentication SDKs available from firebase.google.com/docs/auth/

How can I proceed in this?

I want to use authenticate by Email and Password, And I need to setup db and using fetching & update workflow.

I used below coding part,

index.html

<!-- Firebase -->
<script src="https://cdn.firebase.com/js/client/2.2.4/firebase.js"></script>
<!-- AngularFire -->
<script src="https://cdn.firebase.com/libs/angularfire/1.1.2/angularfire.min.js"></script>

<div class="list">
            <label class="item item-input">
                <span class="input-label">Username</span>
                <input type="email" ng-model="userDetails.userEmail">
                    </label>
            <label class="item item-input">
                <span class="input-label">Password</span>
                <input type="password" ng-model="userDetails.userPassword">
                    </label>
            <button class="button button-full button-positive" ng-click="doLogin()">
                Sign In
            </button>
        </div>

app.js

var starterApp = angular.module('starterApp', ['ionic', 'starterApp.UserOneController','starterApp.UserTwoController','starterApp.UserHomeController','starterApp.UserAccountController','starterApp.services','starterApp.Filters','firebase'])

UserAccountController.js

.controller('UserAccountCtrl', function($scope,$rootScope,$filter,$firebaseAuth,$ionicLoading) {

    $scope.doLogin = function() {


                // Adding fireBase

                var ref = new Firebase("https://sierra-e352f.firebaseio.com");

                var eMail = '[email protected]';
                var userPwd = 'suthm@123';

                ref.createUser({
                               email    : eMail,
                               password : userPwd
                               }, function(error, userData) {
                               if (error) {
                               alert("Error creating user:", error);
                               console.log("Error creating user:", error);

                               } else {
                               alert("Successfully created user account with uid:", userData.uid);
                               console.log("Successfully created user account with uid:", userData.uid);

                               }
                               });


                });

Thanks!

1
The community has discussed begging for ASAP/urgency in questions, and has firmly resolved it is unacceptable.halfer
Please take some time to do atleast the minimal searching on the internet. 5 min search would get you to this site wich explains how to upgrade to firebase 3André Kool
@AndréKool - Actually I gone through the website already but I asked the workflow using ionic and fire base so I confused in this.Suthan M
You've created a project on the new Firebase console (firebase.google.com), but are trying to use a 2.x Firebase SDK against it. This is not a supported combination. To continue, use the new Firebase Authentication SDKs available from firebase.google.com/docs/auth.Frank van Puffelen

1 Answers

1
votes

I can able to access the firebase 3.0 series using ionic and cordova. please find the below workouts and try yours. cheers!

index.html

<!-- Angular -->
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.5/angular.min.js"></script>

<!-- Firebase -->
<script src="https://www.gstatic.com/firebasejs/3.0.3/firebase.js"></script>

<!-- AngularFire -->
<script src="https://cdn.firebase.com/libs/angularfire/2.0.0/angularfire.min.js"></script>

<!-- cordova script (this will be a 404 during development) -->
<script src="cordova.js"></script>

<!-- Firebase Account Setup-->

<script>
//Initialize the Firebase SDK
var config = {
apiKey: "",
authDomain: "",
databaseURL: "",
storageBucket: "",
};

firebase.initializeApp(config);

//Get a reference to the database service
var database = firebase.database();

</script>

Signup.js - using Firebase createUserWithEmailAndPassword

angular.module('starterApp.UserSignupController', ['firebase'])

.controller('UserSignupCtrl', function($scope,$rootScope,$filter,$ionicLoading,$firebaseAuth,$state) {

//Do Login

$scope.userDetails={};

$scope.doFireSignup = function() {

// Accessing this values from HTML Signup UI View

var userName = $scope.userDetails.userName;
var userEmail = $scope.userDetails.userEmail;
var userPassword = $scope.userDetails.userPassword;

$scope.authObj = $firebaseAuth();

//Create a new user
firebase.auth().createUserWithEmailAndPassword(userEmail, userPassword)
.then(function(firebaseUser) {
$scope.message = "User created with uid: " + firebaseUser.uid;
alert($scope.message);
console.log($scope.message);

$state.go('userSignIn');

}).catch(function(error) {
$scope.error = error;
alert($scope.error);
console.log($scope.error);

});
};
});

Sign-In.js using Firebase signInWithEmailAndPassword

var userName = $scope.userDetails.userName;
var userEmail = $scope.userDetails.userEmail;
var userPassword = $scope.userDetails.userPassword;

$scope.authObj = $firebaseAuth();

//Create a new user
firebase.auth().signInWithEmailAndPassword(userEmail, userPassword)
.then(function(firebaseUser) {
$scope.message = "User singed with uid: " + firebaseUser.uid;
alert($scope.message);
console.log($scope.message);

$state.go('tab.userOne');

}).catch(function(error) {
$scope.error = error;
alert($scope.error);
console.log($scope.error);

});