skip to Main Content

My requirement is to display user photos using facebook API. I can do this successfully. But the problem is this, I cannot retrieve the photos of a user without them logging in. Client doesn’t want the user to log in everytime their photos should be displayed. Is this possible?

One solution that I come up with is to generate an access token at developers.facebook.com but the problem with this solution is that users should have prior knowledge in facebook API before they can generate access token and they don’t want this. What my client wants is for users to log in ONCE in the app. And after that, retrieve their photos everytime they access the app. How can I do this? Thanks!!

2

Answers


  1. Chosen as BEST ANSWER

    Thank you for all the answers. I finally managed to solve the issue. as discussed by luschn, the proper workflow should be: 1. Login using facebook API 2. Using the app-id and access token generated, make a call to facebook API to extend the access token using this URL:

    https://graph.facebook.com/oauth/access_token?             
        client_id=APP_ID&
        client_secret=APP_SECRET&
        grant_type=fb_exchange_token&
        fb_exchange_token=EXISTING_ACCESS_TOKEN 
    
    1. This would return new long-live facebook API access token.

    Thank you!


  2. In order to get user photos (no matter if they are public or not), you MUST authorize that specific user with the user_photos permission. You can store the User Token for future calls, and you can extend the User Token to be valid for 60 days. There is no User Token that is valid forever.

    More information about Tokens:

    Btw, hereĀ“s a good login process, if that is the problem: http://www.devils-heaven.com/facebook-javascript-sdk-login/

    How to login in general is explained very well in the docs too: https://developers.facebook.com/docs/facebook-login/

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search