问题
I am trying to write a client side authentication for instagram, however I want to do so without a redirect uri, i will not be hosting a sever.
https://instagram.com/oauth/authorize/?client_id=CLIENT-ID&redirect_uri=REDIRECT-URI&response_type=token
the dev api states this is the implicit way, however i cannot find a solution
回答1:
The short answer is, you cannot do without a redirect uri.
This is how OAuth works. You need at least a uri to receive the access token. The uri could be hosted on localhost using a simple web server though.
回答2:
Follow the Client-Side (Implicit) Authentication flow. Use the credentials from the app you registered at the Instagram developer portal. So change CLIENT-ID and REDIRECT-URI from that url to the credentials of your registered app.
From your app, send the user to that link. If they accept they will be redirected to the redirect uri (which should be somewhere in your app). On the page they get redirected, the page will have a hash containing an acces token.
Get that from the url and use it to request data from the instagram api. You will need jsonp for the requests. See an example in action in a similar thread
来源:https://stackoverflow.com/questions/13160375/how-to-authenticate-instagram-without-redirect-url-no-server