Magento Rest API Oauth URL Returning 404
Asked Answered
B

5

5

From the Magento wiki at:

http://www.magentocommerce.com/api/rest/authentication/oauth_authentication.html#OAuthAuthentication-OAuthProcess

When getting an API token you start off by getting an Unauthorized Request Token at:

www.mystore.com/oauth/initiate

However, my code does not work and when I browse to the above url in my browser I get a 404.

I am appending shop store code to the base url (eg www.mystore.com/en/) I don't know if this alters anything.

Boren answered 23/1, 2013 at 4:0 Comment(4)
do you get 404 or 400 Bad Request?Haycock
Simply loading the url in a browser will not pass the required parameters to the server object, which when trying to initiate a token will fail and throw an exception resulting in 400 Bad request. This one may be mistaken for 404Haycock
It's 404 I plopped: jQuery.post("mydomain.com/oauth/initiate"); Into my chrome console and got: POST mydomain.com/oauth/initiate 404 (Not Found)Boren
can you create consumer app in magento admin?Losel
G
14

The Magento Wiki has a typo:

$adminAuthorizationUrl = 'http://yourhost/admin/oAuth_authorize';

Should be:

$adminAuthorizationUrl = 'http://yourhost/admin/oauth_authorize';
Galimatias answered 30/6, 2015 at 17:15 Comment(1)
+1 - my customer oauth URLs were all working normally, but /admin/oAuth_authorize was 404'ing. Changing the path to all lowercase solved it.Hamer
P
7

I struggled with this one for most of the day, so here's a late contribution in case it helps anybody:

The authorization URL that's documented by Magento, admin/oauth_authorize, assumes that you're not using a custom URL for your admin access. "admin" is the standard URL to access the Magento dashboard, but many people change it for security. If you have changed your admin URL to something other than "admin", use that instead.

IOW if you access your Magento dashboard at https://yoursite.com/foo, then your authorization URL is foo/oauth_authorize.

Peppard answered 22/12, 2016 at 21:10 Comment(1)
thank you!! I spent several hours trying to figure this outLafond
M
5

I also had the problem, that the following request returned the 404 http status:

http://yourmagentostore.com/oauth/initiate

The solution was quite simple: In case if you are using multiple stores and/or store views on the same domain, don't forget to add the url path which maps to the store view. E.g.

http://yourmagentostore.com/<my-store-view-path>/oauth/initiate
Muscarine answered 18/11, 2014 at 15:1 Comment(2)
This worked for me as well (adding the store-view-path to param --request-token-url), however the next step in the oauth dance 404'd, so adding store-view-path to this parameter fixed that: --access-token-url http://yourmagentostore.com/<store>/oauth/tokenHogg
I've literally searched the whole web for this information… Thats why I am hating Magento…!Learnt
H
4

I just had the same problem. Not many similar problems to be found and no solution. This is strange because this seems to be a missing config option 'global/request/direct_front_name', which isn't set in Core/Oauth module. How can all the tutorials work without this important setting!?

Without "oauth" setting being there, every call to /oauth/[controller] leads to "noRouteAction" being resolved (see. Mage_Core_Controller_Request_Http::setPathInfo() and Mage_Core_Controller_Request_Http::isDirectAccessFrontendName($storeCode)) instead of default indexAction.

So, the solution is to set this setting in local config or an own extension as follows

<?xml version="1.0"?>
<config>
  [...]
  <global>
    [...] 
    <request>
        [...] 
        <direct_front_name>
            <oauth/>
        </direct_front_name>
    </request>
  </global>
</config>

Afterwards you can finally get the token at least. I'm checking the further process now.

Highly answered 4/6, 2013 at 10:44 Comment(0)
D
0

There is one subtlety don't forget the http:// so your call to the store should be

http://yourmagentostore.com/oauth/initiate

Also there is more to REST services setup then on the link you posted, it is only an overview. There is a ton of configuration on the store before you will actually get a rest response and when the user isn't recognized, unauthorized or without proper ACL privileges you will get 404 or 500 responses. I guess that deters hackers but it is a bear to trouble shoot. I've been down this road and although I am using an automation tool the Setup of the store and troubleshooting is the same.

Take a look on my blog I keep it up to date with my adventures with the Magento REST API
Cheers!
Rich Borek
http://magento-simplified.blogspot.com

Duenna answered 14/6, 2013 at 16:15 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.