Authenticate with sirv using API Connector

The sirv API requires you get a Bearer token (which expires every 20 minutes)

From their documentation:

Each API call must be authenticated with a bearer token (JSON Web Token). You can get a token with a POST request. Here’s an example in curl:

{
  curl --request POST \
    --url https://api.sirv.com/v2/token \
    --header 'content-type: application/json' \
    --data '{
    "clientId": "CLIENT_ID",
    "clientSecret": "CLIENT_SECRET"
}'

which then gets you this:

{
  "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJjbGllbnRJZCI6IkNMSVlYRjVqMERQV053cWpzdHJWbkNPVFRNbCIsImNsaWVudE5hbWUiOiJUZXN0IGNsaWVudCIsInNjb3BlIjpbImFjY291bnQ6cmVhZCIsImFjY291bnQ6d3JpdGUiLCJ1c2VyOnJlYWQiLCJ1c2VyOndyaXRlIiwiYmlsbGluZzpyZWFkIiwiYmlsbGluZzp3cml0ZSIsImZpbGVzOnJlYWQiLCJmaWxlczp3cml0ZSIsInZpZGVvcyIsImltYWdlcyJdLCJpYXQiOjE1MjIwODExMTYsImV4cCI6MTUyMjA4MjMxNiwiYXVkIjoiNDlnaGEyN2ZraHQzdGtyaml0aWJoNGJrazQxemdqdTgifQ.GkhToMKvy8hB68SNpqpPcxhsMczyyTtlROMvsqiPJ4Y",
  "expiresIn": 1200,
  "scope": [
    "files:read",
    "files:write",
    "videos",
    "images"
    ]
}

and then you use the token for all subsequent calls:

curl --request POST \
  --url https://api.sirv.com/v2/files/video2spin \
  --header 'authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJjbGllbnRJZCI6IkNMSVlYRjVqMERQV053cWpzdHJWbkNPVFRNbCIsImNsaWVudE5hbWUiOiJUZXN0IGNsaWVudCIsInNjb3BlIjpbImFjY291bnQ6cmVhZCIsImFjY291bnQ6d3JpdGUiLCJ1c2VyOnJlYWQiLCJ1c2VyOndyaXRlIiwiYmlsbGluZzpyZWFkIiwiYmlsbGluZzp3cml0ZSIsImZpbGVzOnJlYWQiLCJmaWxlczp3cml0ZSIsInZpZGVvcyIsImltYWdlcyJdLCJpYXQiOjE1MjIwODExMTYsImV4cCI6MTUyMjA4MjMxNiwiYXVkIjoiNDlnaGEyN2ZraHQzdGtyaml0aWJoNGJrazQxemdqdTgifQ.GkhToMKvy8hB68SNpqpPcxhsMczyyTtlROMvsqiPJ4Y' \
  --header 'content-type: application/json' \
  --data '{
	"filename": "/My-Video.mp4"
}'

Neither bubble’s OAuth2 Custom Token nor the JSON web token formats for the API Connector work with this.

Does this mean I can’t use this API, or am I doing something wrong?

Oh man… you can do this, but it’s a pain in the butt to manage the tokens yourself. I’ve done the same thing (as have others here), but it takes like 50 pages of description (I’m not exaggerating) or about a 2 hour video tutorial to explain how to do this.

I never did create such a video because it’s too damn painful. But you can get some helpful hints from this thread (note: I finally figure it out and describe — at a high level — what this entails).

ASIDE: OH GOD THE NEW FONT IN THE COMPOSER ON MOBILE. CANNOT SEE. Bubble please to fix…

Anyway, here’s the link;

1 Like