magento - rest-assured OAuth 1.0a How can I insert both Header and Query params in the request -


magento's 1.9 rest api needs both authorization header , oauth query params, oauth() allows either oauthsignature.header, or query_string

given().auth().oauth(consumer_key, consumer_secret, access_token,              secret_token,oauthsignature.header) 

i tracked code down com.jayway.restassured.internal.httpauthconfig.process(..), not sure here.

q: there filter or method allow me force both?

tl;dr started referring this: how use postman rest client magento rest api oauth. how token , token secret? last statement

note, must check "add params header" checkbox in order magento rest calls work properly.

using postman, oauth 1.0 works when check box , fails when don't, 403 access denied. same response when use oauthsignature.query_string in rest-assured.

works: sent postman (add params header)  /api/rest/products?oauth_consumer_key=<my-consumer-key>&oauth_token=<my-oauth-token>&oauth_signature_method=hmac-sha1&oauth_timestamp=1471929347&oauth_nonce=lj3o2k&oauth_version=1.0&oauth_signature=0any8rq+xjbnwcdxmphfujg1v7o= http/1.1 host: dockerized-magento.local connection: keep-alive authorization: oauth oauth_consumer_key="<my-consumer-key>",oauth_token="<my-oauth-token>",oauth_signature_method="hmac-sha1",oauth_timestamp="1471996573",oauth_nonce="elk9fx",oauth_version="1.0",oauth_signature="svdfmxrwj1o0p2%2fwpoomeveb93c%3d" cache-control: no-cache user-agent: mozilla/5.0 (x11; linux x86_64) applewebkit/537.36 (khtml, gecko) chrome/52.0.2743.82 safari/537.36 postman-token: 9348e805-3c6f-54d7-082f-a1458164725d accept: */* accept-encoding: gzip, deflate, sdch accept-language: en-us,en;q=0.8 

rest-assured oauthsignature.query_string

doesn't work: oauthsignature.query_string  /api/rest/products?oauth_nonce=-316324336&oauth_signature=tlanzu5ogxowyjcpr2v7w448tjw%3d&oauth_token=<my-oauth-token>&oauth_consumer_key=<my-consumer-key>&oauth_timestamp=1471996938&oauth_signature_method=hmac-sha1&oauth_version=1.0 http/1.1 accept: */* content-length: 0 host: dockerized-magento.local connection: keep-alive user-agent: apache-httpclient/4.5.1 (java/1.8.0_77) accept-encoding: gzip,deflate  resp: {"messages":{"error":[{"code":403,"message":"access denied"}]}} 

same failed response using postman out "add params header")

doesn't work: sent postman (no - add params header)  /api/rest/products?oauth_consumer_key=<my-consumer-key>&oauth_token=<my-oauth-token>&oauth_signature_method=hmac-sha1&oauth_timestamp=1471976516&oauth_nonce=otwtnw&oauth_version=1.0&oauth_signature=dsh5teerec9rmbkakta1v2e7ztw= http/1.1 host: dockerized-magento.local connection: keep-alive cache-control: no-cache user-agent: mozilla/5.0 (x11; linux x86_64) applewebkit/537.36 (khtml, gecko) chrome/52.0.2743.82 safari/537.36 postman-token: f9800e1c-b259-f025-cf48-68e483283869 accept: */* accept-encoding: gzip, deflate, sdch accept-language: en-us,en;q=0.8  response: {"messages":{"error":[{"code":403,"message":"access denied"}]}} 

mistake made, header option works fine. postman link above, works fine , great help, led me believe needed both url params , headers. went postman , deleted url params after adding params headers. worked fine. went , found consumer keys wrong.

tip: magento consumer keys , secret not "copyable", use firebug!


Comments

Popular posts from this blog

mysql - Dreamhost PyCharm Django Python 3 Launching a Site -

java - Sending SMS with SMSLib and Web Services -

java - How to resolve The method toString() in the type Object is not applicable for the arguments (InputStream) -