Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialTrino Mitra
11,165 PointsFIREBASE AUTHENTICATION: Has anyone figured out Authentication using AngularFire?
I'm working on a project that uses AngularFire, which is a combination of angular js and firebase. Firebase has it's own authentication methods, which works with google and other platforms, but I am trying to authenticate users through google. Here is a link to the quickstart guide for anyone that is interested: https://www.firebase.com/docs/web/libraries/angular/quickstart.html.
Here is the code that I have:
ng-app is defined in the html tag and ng-controller is defined in the body tag
<head>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.15/angular.min.js"></script>
<script src="https://cdn.firebase.com/js/client/2.2.4/firebase.js"></script>
<script src="https://cdn.firebase.com/libs/angularfire/1.2.0/angularfire.min.js"></script>
</head>
<script>
var app = angular.module("sampleApp", ["firebase"]);
app.controller("SampleCtrl", function($scope, $firebaseAuth) {
var ref = new Firebase("https://authtesting-73ed4.firebaseio.com/data");
var auth = $firebaseAuth(ref);
auth.$authWithOAuthPopup("google").then(function(authData) {
console.log("Logged in as:", authData.uid);
}).catch(function(error) {
console.log("Authentication failed:", error);
});
});
</script>