ChiefComm
ChiefComm

Reputation: 1

How do I use an access id and access key to generate a cwauth-token in Integromat custom app?

I have an Access ID and Access Key from Voluum but I do not know how to write the bit that says, "Here are my credentials, please may I have my auth token?" in json... In the Integromat connection for my custom app.

Once I have the auth token, I know how to use call it in headers → authorization → bearer... I just don't know what to write to generate that token!!

... I have all of this in the Voluum API docs...

POST /auth/access/session Creates session using an access key

Response Class (Status 200) Session creation response

ModelExample Value

{

  "expirationTimestamp": "2022-01-25T16:33:18.188Z",
  "inaugural": true,
  "token": "string"
}

Response Content Type application/json; charset=utf-8 Parameters Parameter Value Description Parameter Type Data Type payload

{
  "accessId": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
  "accessKey": "xxxxxxxxxxxxxxx-xxxxxxxxx_xxxxxxxxxx"
}

Parameter content type: application/json; charset=utf-8 Create session with access key request

body
ModelExample Value

{
  "accessId": "string",
  "accessKey": "string"
}

Hide Response Curl curl -X POST --header 'Content-Type: application/json; charset=utf-8' --header 'Accept: application/json' -d '{ \ "accessId": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", \ "accessKey": "xxxxxxxxxxxxxxx-xxxxxxxxx_xxxxxxxxxx" \ }' 'https://api.voluum.com/auth/access/session' Request URL https://api.voluum.com/auth/access/session Response Body

{
  "token": "string",
  "expirationTimestamp": "2022-01-25T20:45:27.154Z",
  "inaugural": false
}

Response Code 200 Response Headers

{
  "cache-control": "no-cache, no-store, pre-check=0, post-check=0, max-age=0, must-revalidate",
  "content-type": "application/json;charset=utf-8",
  "expires": "Thu, 01 Jan 1970 00:00:00 GMT",
  "pragma": "no-cache"
}

But where the heck does all of this stuff go?? There are other GET / POST bits in the Voluum API docs, I'm just not sure what all I need and in what order. I feel like I have all the pieces to the puzzle but I have never seen the box so I don't know what it's supposed to look like when I'm done!!

Upvotes: 0

Views: 372

Answers (1)

Rafo
Rafo

Reputation: 1

It's been quite some time since you posted this, but I got similar problem and wanted to share my solution. This is a working solution for me (try it in postman, this is exported as PHP - cURL request) First to get token use this call:

<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://api.voluum.com/auth/access/session',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_POSTFIELDS =>'{
  "accessId": "your-access-ID",
  "accessKey": "your-access-token"
}',
  CURLOPT_HTTPHEADER => array(
    'Content-Type: application/json'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

Response will get you token which you need to pass in header like this:

<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://api.voluum.com/conversion',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_POSTFIELDS =>'your-conversion-data-or-anything-else-you-want',
  CURLOPT_HTTPHEADER => array(
    'Accept: application/json',
    'Accept-Charset: utf-8',
    'Content-Type: text/csv',
    'cwauth-token: token-you-got-from-previous-request'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

Note that above I'm using https://api.voluum.com/conversion endpoint, which is for uploading custom conversions, you want to use endpoint which you need and also put your data in CURLOPT_POSTFIELDS

Hope this helps!

Upvotes: 0

Related Questions