Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Load access token into API #38

Open
nivek91 opened this issue Aug 21, 2014 · 4 comments
Open

Load access token into API #38

nivek91 opened this issue Aug 21, 2014 · 4 comments

Comments

@nivek91
Copy link

nivek91 commented Aug 21, 2014

Hi after the user has signed in with facebook. I have result with the access token and the user id. I was trying to pass these 2 things to the ezfb object so the user doesn't have to sign in with facebook again. Is there a way to do this?

My code for login:
ezfb.login(null, {
scope: facebookcfg.scope
}).then(function(res) {
console.log(res);
$facebook.saveFacebookToken(res.authResponse.accessToken, res.authResponse.userID);
});
I want to do this:

$facebook.getFacebookToken()
.then(function(result) {
//TODO: pass result to ezfb: ezfb.loadSignedInData(result.accesstoken, result.userId)
console.log(result);
},
function(result) {
$scope.login();
})

Thanks!

@pc035860
Copy link
Owner

Hi @nivek91 ,

In my understanding, you can use Facebook JS SDK to do what you're attempting to do without saving the access token (Facebook itself doesn't want you to do that either).

Once the user gets connected with your Facebook application and doesn't manually remove the connection, you can simply use ezfb.getLoginStatus() to check for user's connection with your application and start the login process from there.

You can check out the API demo in README.md as an example.

@nivek91
Copy link
Author

nivek91 commented Aug 25, 2014

Hey, first thanks for replying!

I think I was not very clear!

The flow would be like this:
user enters to web site, sign in with facebook credentials (fb user, fb
pass) > response with access token, user id (token: eeab2, user id: 521) >
web site stores access token, user id > web site calls facebook API, for
example get friends. > user leaves the web site and closes browser. Same
user enters to web site, I don't want him to sign in with facebook
credentials again, I just want to call the api because he had already
signed in, so I get the access token, user id from my back end, but I don't
know how to send this data to the facebook api to be able to call the api
without signing in again.

Kevin

On Sun, Aug 24, 2014 at 3:03 AM, Chih-Hsuan Fan [email protected]
wrote:

Hi @nivek91 https://github.com/nivek91 ,

In my understanding, you can use Facebook JS SDK to do what you're
attempting to do without saving the access token (Facebook itself
doesn't want you to do that either).

Once the user gets connected with your Facebook application and doesn't
manually remove the connection, you can simply use ezfb.getLoginStatus()
to check for user's connection with your application and start the login
process from there.

You can check out the API demo http://plnkr.co/edit/qclqht?p=preview in
README.md as an example.


Reply to this email directly or view it on GitHub
#38 (comment)
.

@wmbutler
Copy link

Any headway on this? I'd like the same thing. I just want to be able to send the fb token with the request.

@pc035860
Copy link
Owner

Hey @wmbutler

As long as the user has signed in Facebook and already connected with your FB application.

Simply call .getLoginStatus() before calling .api(), usually you won't have to pass the credentials to FB JS SDK, the JS SDK can share the login status with back-end SDKs with cookie: true parameter.

e.g. http://plnkr.co/edit/qclqht?p=preview

It doesn't require you to login in with Facebook again before calling .api('/me').

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants