Last active
September 15, 2016 09:22
-
-
Save WietseWind/7dbeb33e30f01b32a64f35f8d6851f1a to your computer and use it in GitHub Desktop.
Custom oauth with moreapp and nodum (generate consumer_secret based on password at: https://docs.moreapp.com/#/api/authentication )
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% set url = 'https://api.moreapp.com/api/v1.0/customers' %} | |
{% set consumer_key = '[email protected]' %} | |
{% set consumer_secret = '80a7d446f2e328114994f057e72be827a419eba1' %} | |
{% set nonce = random(999)|md5|slice(0,8) %} | |
{% set time = 'now'|date('U') %} | |
<h1>Signature String</h1> | |
{% set sig_str = 'GET' ~ | |
'&' ~ (url|e('url')) ~ '&' ~ | |
( | |
'oauth_consumer_key=' ~ (consumer_key |e('url')) ~ | |
'&oauth_nonce=' ~ (nonce |e('url')) ~ | |
'&oauth_signature_method=' ~ ('HMAC-SHA1' |e('url')) ~ | |
'&oauth_timestamp=' ~ (time |e('url')) ~ | |
'&oauth_version=' ~ ('1.0' |e('url')) | |
)|e('url') | |
%} | |
{{ sig_str|pre }} | |
<h1>Signature Hash o.b.v. password bij user</h1> | |
<h4>sha1(GeneratedConsumerSecret, Signature ^^)</h4> | |
{% set oauth_sig = api.Crypt_Hash(sig_str, consumer_secret~'&', true, 'sha1' )|base64_encode|e('url') %} | |
{{ oauth_sig|pre }} | |
<h1>Authorization-header (waarde)</h1> | |
{% set auth = 'OAuth realm="more", oauth_timestamp="'~time~'", oauth_nonce="'~nonce~'", oauth_version="1.0", oauth_signature_method="HMAC-SHA1", oauth_consumer_key="'~consumer_key~'", oauth_signature="'~oauth_sig~'"' %} | |
{{ auth|pre }} | |
{% set data = sabre.get(url, { | |
'Authorization' : auth | |
}) %} | |
<h1>Resultaat</h1> | |
{{ data|pre }} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment