Skip to content
This repository has been archived by the owner on Apr 28, 2020. It is now read-only.

Error while accessing Access Token #218

Open
singhal425 opened this issue Apr 29, 2018 · 4 comments
Open

Error while accessing Access Token #218

singhal425 opened this issue Apr 29, 2018 · 4 comments

Comments

@singhal425
Copy link

singhal425 commented Apr 29, 2018

Hi,

I'm getting (java.lang.String) Cannot extract an access token. Response was: {"error_type": "OAuthException", "code": 400, "error_message": "Matching code was not found or was already used."} while accessing access token.

The piece of code I've written to get the access token:

InstagramService service = new InstagramAuthService().apiKey(this.instagramClientId) .apiSecret(this.instagramClientSecret).callback(this.instagramCallbackUrl).build(); String authorizationUrl = service.getAuthorizationUrl(); Verifier verifier = new Verifier(authorizationUrl); try { return service.getAccessToken(verifier); }catch(OAuthException authException) { authException.getMessage(); }

Here, the verifier which is passed is not the code after redirection but the complete authorization URL which I think is the reason of error mentioned at the top. In the verifier, I should be passing the authorization code which I will be getting after hitting https://api.instagram.com/oauth/authorize/?client_id=<CLIENT_ID>&redirect_uri=<CALLBACK_URL>&response_type=code but it asks for credentials which nowhere we're passing. So, I wanna know is there any piece of code written code which I can use to generate the Authorization code or I need to write separate code for that?

@vadimleonov
Copy link

Did you solve this problem ?

@lhatier
Copy link

lhatier commented Sep 24, 2018

I've got the same issue wiht the example. I try to use Java Lib but i've got the Insta page where i have to fill username/password info to get the code afterwords...
Some has resolve this point?

@singhal425
Copy link
Author

I didn't find resolution of that problem. So, as a workaround I generated the access token (since there's no expiry of it) and passed access token to fetch account data.

@k-enzy
Copy link

k-enzy commented Oct 15, 2018

check this.

InstagramAuthenticationTest.java

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants