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

Facebook access token #1

Open
baio opened this issue Apr 28, 2012 · 3 comments
Open

Facebook access token #1

baio opened this issue Apr 28, 2012 · 3 comments

Comments

@baio
Copy link
Member

baio commented Apr 28, 2012

Hi Max,

first of all, great work with your open-mvc. I used DotNetOpenAuth
first and tried to build something exactly like you did; I just
brought the Facebook-Login to work when I thought that there are
surely already variants which are more generic and include more social
networks etc. :-) So thank you for your work, it's working great.

I have just one question to it:
I would also like to save the external systems ID's (for example
Facebook User ID) of the User in my database too. So the question is,
when a user is logged in, how can I get his external system user id
(eg. Facebook User ID)? I know that I can query the Facebook API with
a AccessToken, but I don't know where the AccessToken is either. Maybe
I just don't know about the naming of certain variables, as I was just
into the Facebook API (and not all other Social Networks).
Maybe you explained it somewhere already, I just didn't find it or
maybe its a stupid question.

Anyway, thanks in advance for an advice! :-)

Best Regards

@baio
Copy link
Member Author

baio commented Apr 28, 2012

Hi Michael!

Yes, you can get any external service user-id like this:

//get current user service identifyer
var extIdent = OAuthUserIdentifyer.ServiceIdentifyer;

//check if user logined as facebook user

if (extIdent.ServiceType == OAuthServiceType.Facebook)
{

var facebookApiUserKey = extIdent.ServiceKey;

....

}

This all part of API which can be used but still haven't been documented :( .
Is it ok if I add the question to the project's github issues?

@baio
Copy link
Member Author

baio commented Apr 28, 2012

Hi Max,

thanks for the fast answer! Its very much appreciated ... you probably
save my Saturday-morning coding :-)

I tried it out, but I think either I still don't get some basic, or we
have some 'naming' problems.

Because:

To make requests to the Facebook API I need an "access_token" (as
written here https://developers.facebook.com/docs/authentication/server-side/)
:

   public static FacebookGraph GetCurrentFacebookUser(string acccessToken)
   {
       var request =

WebRequest.Create("https://graph.facebook.com/me?access_token=" +
Uri.EscapeDataString(acccessToken));
using (var response = request.GetResponse())
{
using (var responseStream = response.GetResponseStream())
{
return FacebookGraph.Deserialize(responseStream);
}
}
}

I have built a function how to get the User Details, but I don't know
where to get the accessToken.

The facebookApiUserKey you described isn't the accessToken. Maybe its
something else (which can lead me to the desired accessToken), but I
don't know what to do with it honestly :-)

For example:
My facebookApiUserKey (gott it by using your library with your source
example provided in the response):
11505e58-c84d-b506-1611-2e3fd8d2f4e4
My accessToken (got it by making handshake etc. with facebook
'myself'): AAAEBA...

I hope you know what I mean, thank you very much for your time! And of
course you can publish whatever I send you wherever you want :-)

Best Regards

@baio
Copy link
Member Author

baio commented Apr 28, 2012

Michel, I suppose your accessToken - is access token of your application, and it should be placed into your config file, from where you can read it whenever it is necessary. You can register you app in facebook here http://developers.facebook.com/setup/ and then get access token.
The string with facebook access token in config file :
I actually not expert in facebook API, so hope this help.
Also see OAuthAccountController.OAuth(...) method in source code.
Regards.

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

1 participant