Created
August 4, 2018 03:57
-
-
Save grosscorporation/ed73c18db49ea743c60af91b7807f824 to your computer and use it in GitHub Desktop.
parse server complete cloud http single thread
This file contains 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
let now = new Date (); | |
let ISODate = new Date ( now.toISOString () ); | |
let TimeStamp = ISODate.getTime (); | |
let api_access_key = "api_access_key"; | |
let api_secret_key = "api_secret_key"; | |
let url = "https://test-emoney-services.w-ha.com/api/"; | |
let body = { | |
"subscriber" : { | |
"lastname" : "Martin", | |
"firstname" : "Philippe", | |
"birthdate" : "1986-03-01", | |
"nationality" : "FRA" | |
}, | |
"address" : { | |
"label1" : "12 rue de Stalingrad", | |
"zip_code" : "92800", | |
"city" : "Puteaux", | |
"country" : "FRA" | |
}, | |
"email" : "[email protected]", | |
"tag" : "account_type1" | |
}; | |
let hmac = crypto.createHmac ( 'sha256', api_secret_key ); | |
hmac.update ( api_access_key + ':' + TimeStamp + ':1:' + JSON.stringify ( body ) ); | |
let signature = hmac.digest ( 'hex' ); | |
Parse.Cloud.httpRequest ( { | |
method : 'post', | |
url : url + 'accounts/standard', | |
headers : { | |
'Authorization' : 'AUTH ' + api_access_key + ':' + TimeStamp + ':1:' + signature, | |
'Content-Type' : 'application/json', | |
}, | |
body : body, | |
params : {} | |
} ).then ( function ( httpResponse ) { | |
res.set('x-timestamp', Date.now()); | |
res.status( 200 ).send ( httpResponse.data ) | |
//res.send ( httpResponse.text.data ) | |
}, function ( error ) { | |
res.status( error.code ).send ( error.data ); | |
} ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment