Skip to content
This repository has been archived by the owner on Aug 22, 2019. It is now read-only.

Create an Auth Token

Serban Simu edited this page Nov 3, 2018 · 1 revision

How to create an authorization token

Note: the content fabric set up for the Cal Hacks 5.0 event is using a relaxed form of security to make it easier to operate (basically so you don't have to spend the whole day getting it right)

The authorization token uses a format similar to JWT.

Token format:

Bearer PAYLOAD.SIGNATURE

Where PAYLOAD is a base64 encoded JSON object of this format:

{
    "qspace_id":"ispcjALidS82U9EjuffFUnFWE32dHGG",
    "addr":"0x71b011b67dc8f5c323a34cd14b952721d5750c93",
    "txid":"0xdf4c304b77cfddd6231b3d0f68687d5fd5b8684a9bc11fe2b14febbe838f1c5f"
}

And SIGNATURE is bypassed by allowing a base64 encoded text SIGNATURE (which is U0lHTkFUVVJF)

Example token

Bearer eyJxc3BhY2VfaWQiOiJpc3BjakFMaWRTODJVOUVqdWZmRlVuRldFMzJkSEdHIiwiYWRkciI6IjB4NzFiMDExYjY3ZGM4ZjVjMzIzYTM0Y2QxNGI5NTI3MjFkNTc1MGM5MyIsICJ0eGlkIjoiMHhkZjRjMzA0Yjc3Y2ZkZGQ2MjMxYjNkMGY2ODY4N2Q1ZmQ1Yjg2ODRhOWJjMTFmZTJiMTRmZWJiZTgzOGYxYzVmIn0=.U0lHTkFUVVJF

Example curl command using an authorization token

curl http://localhost:8008/qlibs -H "Authorization: Bearer eyJxc3BhY2VfaWQiOiJpc3BjakFMaWRTODJVOUVqdWZmRlVuRldFMzJkSEdHIiwiYWRkciI6IjB4NzFiMDExYjY3ZGM4ZjVjMzIzYTM0Y2QxNGI5NTI3MjFkNTc1MGM5MyIsICJ0eGlkIjoiMHhkZjRjMzA0Yjc3Y2ZkZGQ2MjMxYjNkMGY2ODY4N2Q1ZmQ1Yjg2ODRhOWJjMTFmZTJiMTRmZWJiZTgzOGYxYzVmIn0=.U0lHTkFUVVJF"  -H "Content-Type: application/json"