Skip to content

[API] OAuth1.0 request token request failing / Consumer key has expired #829

Closed
@nyov

Description

@nyov

While trying to go the long route and get an OAuth1.0 request token via POST /oauth/token/request (as explained in the devdocs) I'm having these issues.

I tested these with both (and getting the same results)

  • a freshly created "Integration" without activating it (only Consumer Key & Secret exist)
  • an activated "Integration" (through the backend) with (unused) Accress Token & Secret

Variant 1, using POST body:

The server returns a HTTP/1.1 500 Internal Server Error.

tcpdump:

POST /oauth/token/request HTTP/1.1
Host: magento2.local
Content-Length: 250
Accept-Encoding: gzip, deflate
Accept: */*
User-Agent: python-requests/2.4.3 CPython/2.7.8
Connection: keep-alive
content-type: application/x-www-form-urlencoded

oauth_version=1.0&oauth_nonce=6b3dcfe588fcc4c6fceefdc10024a41d680f3779&oauth_timestamp=1418902037&oauth_signature=CdC6L9j8NWK6TZwCaI%2Fmevusqcg%3D&oauth_consumer_key=vdowjpsll6bmob27416mw0yx26a00obd&oauth_signature_method=HMAC-SHA1&oauth_callback=oob

HTTP/1.1 500 Internal Server Error
Date: Thu, 18 Dec 2014 11:27:17 GMT
Server: Apache/2.4.10
Set-Cookie: private_content_version=bd03c1e60f365f81666c2093da991bc0; expires=Sun, 15-Dec-2024 11:27:17 GMT; Max-Age=315360000; path=/
Set-Cookie: PHPSESSID=vc9fsu4id7t8fuvia8jjrpa264; expires=Thu, 18-Dec-2014 12:27:17 GMT; Max-Age=3600; path=/; domain=magento2.local; HttpOnly
Set-Cookie: X-Magento-Vary=deleted; expires=Thu, 01-Jan-1970 00:00:01 GMT; Max-Age=0; path=/
Pragma: no-cache
Cache-Control: no-store, no-cache, must-revalidate, max-age=0
Expires: Wed, 18 Dec 2013 11:27:17 GMT
Connection: close
Transfer-Encoding: chunked
Content-Type: text/html; charset=UTF-8

d0
oauth_problem=internal_error%26message%3DNotice%3A+Undefined+index%3A+oauth_version+in+%2Fthis%2Fis%2Fsome%2Fprivate%2Fpath%2Fmagento2.git%2Flib%2Finternal%2FMagento%2FFramework%2FOauth%2FOauth.php+on+line+63
0

Unquoted:
oauth_problem=internal_error&message=Notice:+Undefined+index:+oauth_version+in+/this/is/some/private/path/magento2.git/lib/internal/Magento/Framework/Oauth/Oauth.php+on+line+63

https://github.com/magento/magento2/blob/master/lib/internal/Magento/Framework/Oauth/Oauth.php#L63
That line checks for $params['oauth_version'], but as the dump should show the param is included.

I concluded that Magento2 is now exclusively checking Authorization headers instead.

Variant 2, using Authorization Headers:

The server returns a HTTP/1.1 401 Unauthorized message.

tcpdump:

POST /oauth/token/request HTTP/1.1
Host: magento2.local
Content-Length: 0
Accept-Encoding: gzip, deflate
Accept: */*
User-Agent: python-requests/2.4.3 CPython/2.7.8
Connection: keep-alive
content-type: application/x-www-form-urlencoded
Authorization: OAuth realm="",oauth_nonce="74b6b19dfc80aaa84bf4faf4c548b509cf92a71c",oauth_timestamp="1418903145",oauth_consumer_key="vxklyge1xp45q2o3afwyyjtg8ga15i58",oauth_signature_method="HMAC-SHA1",oauth_version="1.0",oauth_signature="cA84%2Bt0O2ym3cVHE%2FdXz1Pwwn8E%3D"

HTTP/1.1 401 Unauthorized
Date: Thu, 18 Dec 2014 11:45:45 GMT
Server: Apache/2.4.10
Set-Cookie: private_content_version=8a7cda19058a4697834d07a7c0f4c1d4; expires=Sun, 15-Dec-2024 11:45:45 GMT; Max-Age=315360000; path=/
Set-Cookie: PHPSESSID=c9i34gpd023q8h37ogc9b6k0p4; expires=Thu, 18-Dec-2014 12:45:45 GMT; Max-Age=3600; path=/; domain=magento2.local; HttpOnly
Set-Cookie: X-Magento-Vary=deleted; expires=Thu, 01-Jan-1970 00:00:01 GMT; Max-Age=0; path=/
Pragma: no-cache
Cache-Control: no-store, no-cache, must-revalidate, max-age=0
Expires: Wed, 18 Dec 2013 11:45:45 GMT
Keep-Alive: timeout=5, max=100
Connection: Keep-Alive
Transfer-Encoding: chunked
Content-Type: text/html; charset=UTF-8

26
oauth_problem=Consumer+key+has+expired
0

(Consumer key has expired)
This seems to be the real issue here, the expiration time check.

Of course I verified that I'm actually sending the consumer key&secret as displayed in the backend.

As an aside, the library used to build the OAuth requests is mature (and working with magento1).

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions