Keysersoze
Keysersoze

Reputation: 194

How can I retrieve the access token?

I'm working with the Instagram API. I registered an application and get my clientId et clientSecret. I didn't disabled the implicit OAuth.

For the authentication, I use this URL : https://instagram.com/oauth/authorize/?client_id=CLIENTID&redirect_uri=URL&response_type=token

Then, it redirects to my URL with the access_token in parameter.

In PHP, how can I retrieve the access token from the first url?

I tried with curl function. But I can obtain the final redirection which is : URI?access_token=ACCESS_TOKEN

Upvotes: 0

Views: 1170

Answers (1)

Hans Z.
Hans Z.

Reputation: 54118

When using the Implicit grant the Authorization Server (Instagram) will deliver the token on the redirect URI in the fragment part of the URL ("#"). This flow is meant for in-browser Javascript clients and not for server side PHP. In fact the browser will strip off the fragment portion from the URL before calling the server so the PHP code will never see the access token.

You may use the Authorization Code grant that is meant for web server clients like PHP, so response_type=code.

Upvotes: 0

Related Questions