3

I followed http://devdocs.magento.com/guides/m1x/api/rest/authentication/oauth_configuration.html

I am able to login to "My first application" with admin.

But not with customer.

I got $_SESSION like

Array
(
    [secret] => 7664a04e54256c135a18b313a9d06872
    [state] => 2
    [token] => fc5be1e6d0cd1cde0ed614281b61894f
)

I got error in this line

$oauthClient->fetch($resourceUrl, array(), 'GET', array('Content-Type' => 'application/json'));

Saying that

Invalid auth/bad request (got a 500, expected HTTP/1.1 20X or a redirect)

Service temporary unavailable

Please help me solve this.

8

It seems you should to add "'Accept' => 'application/json'" or 'Accept' => /. So

$oauthClient->fetch($resourceUrl, array(), 'GET', array('Content-Type' => 'application/json'));

should to be

$oauthClient->fetch($resourceUrl, array(), 'GET', array('Content-Type' => 'application/json', 'Accept' => 'application/json'));

or

$oauthClient->fetch($resourceUrl, array(), 'GET', array('Content-Type' => 'application/json', 'Accept' => */*));
  • omg, you saved my day ! – florian-do Aug 26 '16 at 13:02

Not the answer you're looking for? Browse other questions tagged or ask your own question.