How do I create an oauth_signature for OAuth-based authentication in Magento 2.0 REST API requests?

Assuming I use PHP's hash_hmac:

hash_hmac ( 'sha1' , $string , 'Integrations-Consumer-Secret' );

I'm not sure what $string should contain

  • If you get answer, please reply back
    – Jay Momaya
    Commented Apr 17, 2020 at 18:06

1 Answer 1


It is possible to use Access token as bearer token in Authorization header (OAuth 2.0 style), instead of creating signature (OAuth 1.0a style).

Header name: Authorization, Header value: Bearer access_token_goes_here

If you still want to sign request in 1.0a style, then consider using some library, e.g. PHP OAuth extension

  • Perhaps I'm missing something but the docs seem to suggest I need to build a far more complex Authorization header: devdocs.magento.com/guides/v2.0/get-started/authentication/…
    – GuyC
    Commented Dec 4, 2015 at 13:37
  • Try token-based one devdocs.magento.com/guides/v2.0/get-started/authentication/… The one you mentioned is for systems like ERP, which have multiple users behind them. @GuyC What is your integration use case? Commented Dec 4, 2015 at 13:39
  • We're integrating a 3rd Party Web Application, the token based method seemed to target mobile app's? I wanted to have users log into Magento via another site, and then let the other site connect via the OAuth API to grab the required Magento data for that user's session.
    – GuyC
    Commented Dec 4, 2015 at 13:44
  • Unfortunately such case is not supported. There is no endpoint on Magento side to which you may redirect users for authorizing with Magento credentials (for OAuth tokens generation). As a workaround, you may ask user to enter their Magneto credentials somewhere on your side and use these credentials to obtain access token for their account (but users should trust your application enough in this case). Commented Dec 4, 2015 at 13:53
  • Ok, so instead we use token authentication and pass the users username & password to magento with the method you detailed above? Thank you for your help with this
    – GuyC
    Commented Dec 4, 2015 at 13:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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