I'm following Instagram's instruction to learn how to get access_token.
I stucked in the step 3. I have tried to use curl and python script to connect, but both failed.
Here is my curl code:
curl -F 'client_id=MY_CLIENT_ID’ \
-F 'client_secret=MY_CLIENT_SECRET’ \
-F 'grant_type=authorization_code’ \
-F 'redirect_uri=http://localhost' \
-F 'code=MY_CODE' \
https://api.instagram.com/oauth/access_token
The return is showed as below
curl: (6) Couldn't resolve host ' '
curl: (6) Couldn't resolve host ' '
curl: (6) Couldn't resolve host ' '
curl: (1) Protocol " https" not supported or disabled in libcurl
But curl I used already support ssl
.
Then I tried python, here is the code(Thanks for @avinash showing me the single quote problem, but still failed)
url = 'https://api.instagram.com/oauth/access_token'
values = {
"client_id" : "MY_CLIENT_ID",
"client_secret" : "MY_CLIENT_SECRET",
"grant_type" : "authorization_code",
"redirect_uri" : "http://localhost",
"code" : "MY_CODE"
}
data = urllib.urlencode(values)
req = urllib2.Request(url, data)
response = urllib2.urlopen(req)
the_page = response.read()
Just get the error urllib2.HTTPError: HTTP Error 400: BAD REQUEST
.
Can anyone help me figure out what's wrong here? Thanks!