Retrieve data from authenticated users via facebook RRS feed

  • Question

  • User-1352156089 posted
    Hi all,

    I have one question regarding the data that can be retrieved from an authenticated user via facebook. We know we can store name, last name and birthday.

    What about if we would like to retrieve data like the places/location visited by these users?

    Do you think it is possible? If yes, how can we recall this data using asp.net identity?

    Thursday, December 4, 2014 6:19 PM

All replies

  • User-734925760 posted


    So far as I know, if you want to get the Places/location, you need to store the data into table,  also you can design a class with these two fields, then you can get them.

    Hope it's useful for you.

    Best Regards,

    Michelle Ge

    Friday, December 5, 2014 4:36 AM
  • User1779161005 posted

    You would need to read the FB docs to see what data they offer, and then you request that data via the scopes property on the FB options. Those values will then be made available in the authenticated event on the provider in the FB options.

    Friday, December 5, 2014 5:15 AM
  • User-1352156089 posted

    Hi and thanks for your comments.

    I have read all the documentation provided in https://developers.facebook.com/docs/facebook-login/permissions/v2.2 and I am studying the totorial provided in http://blogs.msdn.com/b/webdev/archive/2013/10/16/get-more-information-from-social-providers-used-in-the-vs-2013-project-templates.aspx.

    My aim is to retreive from facebook data such as email, first name, last name, birthday and user tagged places.

    I started to modify my Startup.Auth.vb (I am using Webforms) as per below:

        Dim MyFacebookOptions = New FacebookAuthenticationOptions()
           MyFacebookOptions.AppId = "xxxxxxxxxxxxxx"
           MyFacebookOptions.AppSecret = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
            MyFacebookOptions.Provider = New FacebookAuthenticationProvider() With {.OnAuthenticated = Function(context)
                                                                                                           'Get the access token from FB and store it in the database and
                                                                                                           'use Facebook SDK to get more information about the user
                                                                                                           context.Identity.AddClaim(New System.Security.Claims.Claim("FacebookAccessToken", context.AccessToken))
                                                                                                       End Function
            MyFacebookOptions.SignInAsAuthenticationType = DefaultAuthenticationTypes.ExternalCookie

    However, the above code (which has been translated from C# to VB) gives the following 2 problems:

    1) In Visual Studio the following alert is notified: The function ' < anonymous method > ' does not return a value on all code paths . You may be returned due to an exception with a reference value null at runtime when using the result.

    2) If I test my project, I receive the following error from facebook: Invalid Scope: first_name

    Does anybody know where I am missing something and how to correct it? I am just trying to develop my project basing it on http://blogs.msdn.com/b/webdev/archive/2013/10/16/get-more-information-from-social-providers-used-in-the-vs-2013-project-templates.aspx and trying to translate it from MVC C# to WebForms in VB.

    Thank you

    Monday, December 8, 2014 12:51 PM
  • User-1352156089 posted

    Thank you

    unfortunately for me I am giving up with OWIN and Oauth 2.0.

    I'll need to find an alternative way in order to retrieve additional data from Facebook (more than the email) and store it into the database.

    There is no documentation at all on how to add custom Facebook claims and store them into database with WebForms projects. When I port the http://blogs.msdn.com/b/webdev/archive/2013/10/16/get-more-information-from-social-providers-used-in-the-vs-2013-project-templates.aspx code from C# to VB and adapt it to WebForms, many errors are generated and honestly the code is something that should be better explained and supported by examples for all platforms and not only MVC. By the way, not even the "working example" in https://github.com/rustd/FBLogin works so I guess that I will need to wait for more examples or books about this topic and it looks like this system is still too much new and that needs many improvements from all aspects.

    Thank you

    Saturday, December 13, 2014 11:03 AM