titarenko / OAuth2

OAuth2 client implementation for .NET
412 stars 154 forks source link

Instagram Problem #129

Open Ealireza opened 5 years ago

Ealireza commented 5 years ago

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 commented 5 years ago

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 notifications@github.com 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 .

Ealireza commented 5 years ago

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 commented 5 years ago

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 commented 5 years ago

possible send correct code ? i dont know what to do

niemyjski commented 5 years ago

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

Ealireza commented 5 years ago

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 commented 5 years ago

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.