Search code examples
instagraminstagram-api

Get Instagram access token without login screen


I'm integrating the new Instagram API into a website and using C# for the backend. I'd like to fetch and display photos that match a specific hashtag on my web pages.

Is there a way to access these photos without requiring each user to go through a login screen to obtain an access token? For instance, I can view tags publicly on Instagram web pages, such as https://www.instagram.com/explore/tags/ciao/, without logging in.

If direct access is not possible, is there a way to authenticate on behalf of the user through the API and bypass the login screen?

Thank you for any insights or suggestions.


Solution

  • From the Instagram API docs:

    You can retrieve photos with a given hashtag by accessing the following URL with your access_token (replace ACCESS-TOKEN with your own):

    https://api.instagram.com/v1/tags/nofilter/media/recent?access_token=ACCESS_TOKEN
    

    The Instagram API requires an access_token from authenticated users for each endpoint. We no longer support making requests using just the client_id.

    This access_token does not need to be your user's token. It could be your token instead. But it has to be somebody's.

    Just make sure to review the rate limit documentation also. Rate limits are separate for each access token, so you may need to generate a number of access tokens and round-robin them. You could also allow your users to login if they want, and use their access token if they're logged in.