agnostack/magento_extension

Connection to API - different admin path URL not working

Closed this issue · 9 comments

Because of security reasons we have changed the default admin path for the backend (URL) within our local.xml.
I noticed that it is not possible to connect the API from Zendesk to Magento when this is not '.../admin'.

image 2015-07-09 at 10 58 24 vorm

I found an entry within the file '/app/code/community/Zendesk/Zendesk/conrollers/ApiController.php'
image 2015-07-09 at 10 54 45 vorm

I've been trying to make some changes but this isn't working.

However, when I use the default settings it's able to connect:

image 2015-07-09 at 11 00 10 vorm

Any ideas? Thank you

Having the same issue.

jwswj commented

You could manually customize the code to get this working for now. Does anyone have examples of how this should be handled for Magento plugins? If you could share them with us it would be great. Even better submit a pull request with the changes.

Also have this same issue

I don't know which lines to change but make sure that you don't overwrite the core files of the plugin.
So, just copy the necessary file from ../app/code/community/Zendesk/... to ../app/code/local/Zendesk/...

Otherwise your changes are gone after an update of the extension. Any further ideas how to fix/improve that?

I have had this problem by just using store codes in urls.

I don't believe that the Zendesk people have any idea about how to get their software to work with Magento in 'common use cases'.

I decided to 'fix' this by picking up 404 'no-route' errors in Magento and then re-routing them to the correct url, i.e. by swapping 'index.php' in the url for 'en_us' (yes 'en_us' is the store code for my US store front.).

This I put in my custom module:

        if(strpos($current, 'index.php/zendesk/api')!==false) {

            $redirect = str_replace('index.php', 'en_us', Mage::helper('core/url')->getCurrentUrl()); // Need query string
            Mage::app()->getResponse()->setRedirect($redirect, 302)->sendResponse();
            Mage::log("Redirecting Lame^H^H^H^HZendesk request from ".Mage::helper('core/url')->getCurrentUrl()." to ".$redirect);
            exit(0);

        }

If Zendesk wasn't locked in to numerical id's for things then I would write this more neatly so as to get the first store code and use that in the URL. Obviously my solution will break at the first chance, i.e. if the store codes get changed.

This is a store code problem... for sure. It works when I disable them and obviously it also works with a custom admin path. Where did you make these changes? Any other ideas how to fix that?
Additional note:
I found this:
https://github.com/zendesk/magento_app/pull/33

It seems they already know the problem but it doesn't work with the current Magento zendesk app.

Ok I have fixed the problem. Thanx to @jwswj
Just include this modification and create a custom app within Zendesk.
https://github.com/zendesk/magento_app/pull/33

There you will see a new textfield for the store code. Take the main code and it works.
Test:

curl -X GET -H 'Authorization: Token token="123your0token456"' http://yourdomain.com/index.php/yourstorecode/zendesk/api/customers/customer@domain.com
jwswj commented

@grindking good to see you got your solution working, but I don't think it fully gets to the bottom of the issues described in this thread:

  • Testing a connection to the API doesn't work with a different admin URL
  • The integration out of the box doesn't admin url
    If anyone else comes across these please add a comment here or open a new issue so we can understand the exact use-cases.

@mshaw42 we aren't Magento experts which is why we had this extension built by Magento contactors in the past, we've now got an internal team who is coming up to speed and starting to learn the best practices to continue to evolve this integration and plus many others that we have.

@grindking & @mshaw42 Thanks for providing work-arounds for now.

@jwswj
Yes that is true, it's not a 100% solution. The testing is not working with another URL and the current app from Zendesk does not include the store-code field. I hope there will be an update soon.
Thanks again.