Skip to content
Advertisement

How to pass storeUrl to default Magento oauth script?

I’m trying to create my first Magento 2 extension and integration and I’ve been following the guide in their docs here. All good so far, I’ve completed the auth handshake, stored all the required keys for api requests and can make requests back to my extension fine.

Looking at the OauthClient.php script provided at the foot of the tutorial, the url is hardcoded like so: return new Uri('http://magento.host/oauth/token/request'); and the tutorial advises you to “Change the instances of http://magento.host in this example to a valid base URL.”

JavaScript

My Question is how do I pass the url from the store that the integration has been set up on back as a variable in here?(I have it stored in my db)

Thanks for taking the time to take a look.

Advertisement

Answer

For anyone who might come across this in future after getting the saved data from the table in my db, I added the Url into the call to make the new class on the checklogin.php script in the documentation:

$oAuthClient = new OauthClient($credentials,$magentoBaseUrl);

And then in OauthClient.php, I added the url to the construct and updated the getRequestTokenEndpoint method and the getAcessTokenEndpoint:

JavaScript
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement