Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Instagram Problem #129

Open
Ealireza opened this issue Jun 24, 2019 · 7 comments
Open

Instagram Problem #129

Ealireza opened this issue Jun 24, 2019 · 7 comments

Comments

@Ealireza
Copy link

Ealireza commented Jun 24, 2019

I tried Google ,.. They seams be okey
but Instagram not working

i get code , but on verification , it failed.

after checking response from sent request i seen this


POST https://api.instagram.com/oauth/access_token HTTP/1.1
Accept: application/json, text/json, text/x-json, text/javascript, application/xml, text/xml
User-Agent: RestSharp/106.5.4.0
Connection: Keep-Alive
Accept-Encoding: gzip, deflate
Content-Type: application/x-www-form-urlencoded
Content-Length: 220
Host: api.instagram.com

code=ad7c8347d8b34e5498230c69c7cf66bc&client_id=clientid&client_secret=secret&redirect_uri=http%3A%2F%2Flocalhost%3A3777%2Finstagram%2Foauth&grant_type=authorization_code

{"error_type": "OAuthException", "code": 400, "error_message": "Matching code was not found or was already used."}

it's Instagram problem?
or some thing else

any solution ?

@niemyjski
Copy link
Collaborator

niemyjski commented Jun 25, 2019 via email

@Ealireza
Copy link
Author

Ealireza commented Jun 25, 2019

this is my code

      [Route("/instagram/oauth")]
       public IActionResult callbackx(string code)
       {
           var i = new InstagramClient(new RequestFactory(), new OAuth2.Configuration.ClientConfiguration
           {
               ClientId = "84f00af332c141638db27bab3af6c7e2",
               ClientSecret = " 46d77a1af76644e2a04ee9051cba19db",
               RedirectUri = "http://localhost/instagram/oauth",
               Scope = "basic"
           });
           var e = i.GetUserInfoAsync(new System.Collections.Specialized.NameValueCollection() { { "code", code.Trim() } }).Result;
       }

the code that passed to this route , is okay .
i tried that code with curl , and it working .

but i suspicious to GetUserInfoAsync method of Instagram.

it seams that method send request to Instagram multiple time and cause of error and exceptions .
because Instagram only allow one time to get user info and expire token

@niemyjski
Copy link
Collaborator

You're callback is going to send back the grant_type as a query string parameter that's going to get lost is one issue. Can you import the source and step through it.

@Ealireza
Copy link
Author

possible send correct code ?
i dont know what to do

@niemyjski
Copy link
Collaborator

I'd start by pulling in our source code and stepping through it.

@Ealireza
Copy link
Author

dear sir after a mount i come back here , to check is it work or not

still have problem with Instagram user info


UnexpectedResponseException: Exception of type 'OAuth2.Client.UnexpectedResponseException' was thrown.

OAuth2.Infrastructure.RestClientExtensions.ExecuteAndVerify(IRestClient client, IRestRequest request)

any way to fix ?

@niemyjski
Copy link
Collaborator

I'd clone and reference the project and step through the call. I'd look at the returned json and look at what we are serializing it into. I think that will lead to this error and we can get to what's causing it. I don't use instagram, and we are both developers using this open source project, your help is appreciated.

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

No branches or pull requests

2 participants