Search code examples
djangoinstagram-apifacebook-access-token

How can I get the code from Server side using Instagram Basic Display API?


I am new to Instagram Basic Display API. All I need is to get the recent media published on my Instagram account. I have followed all the steps mentioned here until step 4. In step 4 when I am accessing the authorize URL it is asking me to log in to my test user instagram account first and then displaying the authorized window. Just imagine this from a user perspective. If a user is clicking on a button and if it is asking for entering the credentials of my account it seems to be like exposing my account details publicly. Once I click on the authorize button it is redirecting to my redirect_uri and I can get the code.

How can I implement the same from the server-side? There will be no user interaction for the project I am working on. It should happen from the backend itself. I am using Django as the backend server. Please help me with this.


Solution

  • If this is just for your own project and your own Instagram account you can generate access token like it's described here: https://developers.facebook.com/docs/instagram-basic-display-api/overview/#user-token-generator

    You don't need the authorization window in that case. On your server just write a code that will send the request to Basic Display API with token created via Token Generator.