OAuth2 icon indicating copy to clipboard operation
OAuth2 copied to clipboard

Instagram Problem

Open Ealireza opened this issue 6 years ago • 7 comments

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 ?

Ealireza avatar Jun 24 '19 13:06 Ealireza

Hello,

I'm not sure, you should remove your secret and client id (even refresh those as you just leaked them). I'd recommend stepping through the calls or look at them in fiddler. It looks like the code was already used, was multiple calls using that specific code?

Thanks -Blake Niemyjski

On Mon, Jun 24, 2019 at 8:37 AM Ealireza [email protected] wrote:

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=84f00af332c141638db27bab3af6c7e2&client_secret=46d77a1af76644e2a04ee9051cba19db&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? of some thing else

any solution ?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/titarenko/OAuth2/issues/129?email_source=notifications&email_token=AAHZFI4JSYHNKT5OTM75JFTP4DE2DA5CNFSM4H26XCQ2YY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4G3JPAYA, or mute the thread https://github.com/notifications/unsubscribe-auth/AAHZFI7GMBIAUA3SDCPWBATP4DE2DANCNFSM4H26XCQQ .

niemyjski avatar Jun 25 '19 12:06 niemyjski

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

Ealireza avatar Jun 25 '19 17:06 Ealireza

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.

niemyjski avatar Jun 26 '19 12:06 niemyjski

possible send correct code ? i dont know what to do

Ealireza avatar Jun 26 '19 12:06 Ealireza

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

niemyjski avatar Jun 27 '19 15:06 niemyjski

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 ?

Ealireza avatar Jul 24 '19 08:07 Ealireza

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.

niemyjski avatar Jul 28 '19 11:07 niemyjski