I am using the example provided with polymer here: In the polymer documentation
Or directly from this example x-login
but what I need now is to take the mail of the user in facebook for example, in the code in this part:
<h3>User ID:</h3>
<pre>{{user.uid}}</pre>
they use the user.uid to obtain the ID from facebook but I want also the mail, and the name, but I can't get those :(, do you know how to do that?
Thanks a lot
I suppose you are not using the "scope", in the optional third parameter of authWithOAuthPopup method.
ref.authWithOAuthPopup("facebook", function(error, authData) {
if(error) {
console.log("Esto es un Error", error.message);
} else {
console.log("Ok", authData);
}
},{
scope: 'email'
});
In the Facebook developers documentation you will find the diferent permissions you can ask for. Some of them you will need to validate your app in the app facebook dashboard.
https://developers.facebook.com/docs/facebook-login/permissions
Related
I want to build an Ionic application with WordPress back-end.
I Installed JSON API user,and I want to use Facebook login, but I can not figure it out how I will call the token and pass it to the JSON page. Please any recommend any good article about these technologies, it will help a lot.
Thank you.
Its very easy, once you have configured Facebook.
You must have FB plugin
installed. Once you call facebook cordova plugin you will get token in response after you try to call fb.login.
And then you can call fb connect function and pass access_token
getWPToken(facebooktoken){
this.http.get('yourdomaindotcom/json-api/user/fb_connect/?
access_token='+token).map(res => res.json()).subscribe(data => {
console.log(data);
this.cookie = data.cookie;
this.storage.get('wp_cookie').then((val)=>{
this.storage.set("wp_cookie", this.cookie);
this.event.publish("cookie",this.cookie);
});
},
err => {
console.log("Oops!");
});
}
I tried great example angularjs todo app:
https://github.com/danielzen/todo-ng-pouchdb
and now I'm trying use it with some authentication plugin, but without success ( https://github.com/nolanlawson/pouchdb-authentication ). Todo app use some old angular-pouchdb lib.
Please do you have any tip to example where is used angular, pouchdb and auth plugin to login, signup to couchdb.
My problems with log into CouchDb were because of wrong auth params, I didn't wrap login values into array with key auth.
So just example of correct call to server:
$scope.sync = $scope.tasks.$db.replicate.sync('http://www.server.info:5984/' + dbName,
{live: true, "auth": {username:"john", password:"secret"}})
.on('error', function (err) {
});
I've created a Cordova/Angular app that pulls a Facebook feed from the api. I'm now trying to add the ability to share one of the Facebook posts on your own timeline. I'm using the Cordova Facebook plugin found here https://github.com/jeduan/cordova-plugin-facebook4
The problem is that when I try to share an image post I just get a "An error occurred. Please try again later" in the Share dialog that appears. I'm not sure how to setup the options to share images properly.
Here's my current code for the share:
var options = {
method: 'share',
href: post.link,
caption: post.message
};
$cordovaFacebook.showDialog(options).then(
function (res) {
success(res);
},
function (error) {
console.log(error);
fail(error);
});
Any ideas what the options should be to share an image?
I'm currently using Firebase's AngularFire and trying to login with some code I found in their documentation for facebook logins.
This is my html code (with ng-click to start login):
<a ng-click="loginWithFacebook()" class="btn btn-block btn-social btn-facebook">
This is what my angularjs code looks like (I've set up a login controller):
var app = angular.module("loginApp", ["firebase"]);
app.controller("loginCtrl", function($scope, $firebaseObject) {
var ref = new Firebase("firebaseUrl");
$scope.loginWithFacebook = function() {
ref.authWithOAuthPopup("facebook", function(error, authData) {
if (error) {
console.log("Login Failed!", error);
alert("That didn't work");
} else {
console.log("Authenticated successfully with payload:", authData);
document.write("You're logged in!");
}
});
};
So when I click, the button works except it keeps giving me this error message:
Error: There are no login transports available for the requested method.
at Error (native)
at yg (https://cdn.firebase.com/js/client/2.2.4/firebase.js:139:1271)
at https://cdn.firebase.com/js/client/2.2.4/firebase.js:160:141
I've taken a look in the documentation for firebase, and the error message and explanation is pretty cryptic and I have no idea what it means.
Could someone tell me whats going on and how I can be able login using Facebook and invoke a Facebook popup?
Just realized I still have this question unanswered:
I actually realized that it was merely because I didn't have a Web server set up to handle API calls to Firebase, it was a silly mistake on my part and I will leave this here for future Firebase users so that they understand that you would have to either use nodejs/rails or other backend frameworks to handle API calls or use something like Github Pages to just host your code online.
I want to access the user_name/email_id of the user who logs onto my website using Google+ API. So far I have implemented the Google+ API and the return value is:
User Logged In This is his auth tokenya29.AHES6ZRWhuwSAFjsK9jYQ2ZA73jw9Yy_O2zKjmzxXOI8tT6Y
How can I use this to get the username/email id?
Specifically for retrieving an email address of an authenticated user, keep in mind that you will need to include the userinfo.email scope and make a call to the tokeninfo endpoint. For more information on this, see https://developers.google.com/+/api/oauth#scopes.
if you are correctly logged in, it's enough to call the Google+ api at this URL:
GET https://www.googleapis.com/plus/v1/people/me
where the userId has the special value me, to get all the information about the logged user. For more information see:
https://developers.google.com/+/api/latest/people/get
I'm adding a code sample to help others.
In this case the login operation is performed against Google requesting email, as well as user profile information like name,.... Once all this information is retrieved, a request to my own login service is performed:
function OnGoogle_Login(authResult) {
if (authResult['access_token']) {
gapi.client.load('oauth2', 'v2', function()
{
gapi.client.oauth2.userinfo.get().execute(function(userData)
{
$("#frmLoginGoogle input[name='id']").val(userData.id);
$("#frmLoginGoogle input[name='name']").val(userData.name);
$("#frmLoginGoogle input[name='email']").val(userData.email);
$.ajaxSetup({cache: false});
$("#frmLoginGoogle").submit();
});
});
}
}
$(document).ready(function() {
/** GOOGLE API INITIALIZATION **/
$.ajaxSetup({cache: true});
$.getScript("https://apis.google.com/js/client:platform.js", function() {
$('#btnLoginGoogle').removeAttr('disabled');
});
$("#btnLoginGoogle").click(function() {
gapi.auth.signIn({
'callback': OnGoogle_Login,
'approvalprompt': 'force',
'clientid': 'XXXXX.apps.googleusercontent.com',
'scope': 'https://www.googleapis.com/auth/plus.login https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/userinfo.email',
'requestvisibleactions': '',
'cookiepolicy': 'single_host_origin'
});
});
});