Problems with Magento oauth and REST api

I am trying to integrate my ruby ​​in a rails application with magento, and I got to the point where I made the initial request, got permission, and I believe that I get the last token, but I can not be sure. Here is what I have in my answer:

(There are a lot of things here, so skip ahead to where I will rip out the import bit)

..... "credentials"=> {"token"=>"r8apb2rcgci9ry5hugcuiqlnwdi0evc1", "secret"=>"8pnyogb4048toujt5rjoq26tqh50vkv5"}, "extra"=> {"access_token"=> #<OAuth::AccessToken:0x007fdd59893468 @consumer= #<OAuth::Consumer:0x007fdd5995f928 @http=#<Net::HTTP mymagentocart.dev:443 open=false>, @http_method=:post, @key="ttuj6ok0ioziv7bcfwi8wprzqe6o4x1e", @options= {:signature_method=>"HMAC-SHA1", :request_token_path=>"/oauth/initiate", :authorize_path=>"/admin/oauth_authorize", :access_token_path=>"/oauth/token", :proxy=>nil, :scheme=>:header, :http_method=>:post, :oauth_version=>"1.0", :site=>"https://mymagentocart.dev"}, @secret="b0maut2ftkg2wb3nm24t263720n7kxqa">, @params= {:oauth_token=>"r8apb2rcgci9ry5hugcuiqlnwdi0evc1", "oauth_token"=>"r8apb2rcgci9ry5hugcuiqlnwdi0evc1", :oauth_token_secret=>"8pnyogb4048toujt5rjoq26tqh50vkv5", "oauth_token_secret"=>"8pnyogb4048toujt5rjoq26tqh50vkv5"}, @secret="8pnyogb4048toujt5rjoq26tqh50vkv5", @token="r8apb2rcgci9ry5hugcuiqlnwdi0evc1">}, "oauth_token"=>"jj2dbrea7dimxwc0twibyoikxjazvs6y", "oauth_verifier"=>"83idqmtmb76fe5axad1rf7lhfa3wqxki" ..... 

I see my key and secret in the access token:

 @key="ttuj6ok0ioziv7bcfwi8wprzqe6o4x1e" @secret="b0maut2ftkg2wb3nm24t263720n7kxqa" 

This is what magento gave me when I created the REST user in the admin.

Then theres a bunch of duplicate tokens and secrets, but theyre all the same and fall under the label "credentials":

 "token"=>"r8apb2rcgci9ry5hugcuiqlnwdi0evc1" "secret"=>"8pnyogb4048toujt5rjoq26tqh50vkv5" 

Finally, theres oauth_token and oauth_verifier:

 "oauth_token"=>"jj2dbrea7dimxwc0twibyoikxjazvs6y" "oauth_verifier"=>"83idqmtmb76fe5axad1rf7lhfa3wqxki" 

So here is my problem ...

Which one do I need to transfer with future authentication requests right away without requiring token regeneration?

In my application now, every time I make a request, it sends me back to the user confirmation screen in purple for authorization.

In addition, how can I make a request for a user ID, name, etc. magento, so can I create a user in a rails application using this information?

Thanks!

+4
source share
1 answer

You have an access token object so you can do something like this:

 auth_hash["extra"]["access_token"].get("/api/rest/products") 

If you want to create a new access token, you can do the following with the keys and tokens that I pulled from your example:

 @consumer=OAuth::Consumer.new("ttuj6ok0ioziv7bcfwi8wprzqe6o4x1e", "b0maut2ftkg2wb3nm24t263720n7kxqa", {:site => "https://mymagentocart.dev"}) @access_token = OAuth::AccessToken.new(@consumer, "r8apb2rcgci9ry5hugcuiqlnwdi0evc1", "8pnyogb4048toujt5rjoq26tqh50vkv5") @access_token.get("/api/rest/products") 

See β€œUsing a Long Access Token” on this page: http://code.google.com/p/oauth-plugin/wiki/AccessToken

0
source

All Articles