Generating a token to be used in your application is actually fairly straightforward once you know the magical incantation. Just do the following:
In order to generate instagram token you have to login to Instagram account for which you want to generate the token. Once logged in visit the Instagram Developer‘s site and go to Manage client >> Register a new client.
Fill in all the details and click on register. Once you have successfully registered you will get your app details listed under Manage Client option.
You can see Delete & Manage buttons against your app. Click on Manage and go to security tab and uncheck Disable implicit OAuth: checkbox and click on Update Client.
Write down the client ID, client secret, and redirect URI for the client you have created and need an access token for.
Now visit the following address replacing the {client ID} and the {redirect_uri} in your browser.
https://www.instagram.com/oauth/authorize/?client_id={client_id}&redirect_uri={redirect_uri}&response_type=token
You will be soon redirected to your redirect url with access token in the url. Make a note of it.
example
https://example.com/#access_token=123456789.G123h12.123abcd4567efgh3456ojdg83hdk73556js
How to get Instagram account ID
Instagram account id is numeric id generated by instagram for your account. In case if you don’t know your account id you can get by below two methods.
- Visit below url by replacing {user_name} with your instagram username and make a note of “id”:”XXXXXXXX”. here XXXXXXXX is account id of the username provided.
https://www.instagram.com/{user_name}/?__a=1
2nd method include console feature in browser’s web console. You can use either chrome or firefox and press ctrl+shift+i or go to developers console. Open your instagram profile in the browser and type below code and press enter, you will get your account id in response. You might need to refresh the page for this to work though.
window._sharedData.entry_data.ProfilePage[0].graphql.user.id