Add scripts

This commit is contained in:
Mark Veidemanis 2021-12-23 00:29:33 +00:00
parent 49d4d3e976
commit 25ace1d8b2
Signed by: m
GPG Key ID: 5ACFCEED46C0904F
3 changed files with 34 additions and 0 deletions

7
scripts/get-token.sh Executable file
View File

@ -0,0 +1,7 @@
curl https://sandbox-b2b.revolut.com/api/1.0/auth/token \
-H "Content-Type: application/x-www-form-urlencoded"\
--data "grant_type=authorization_code"\
--data "code=oa_sand_[...]"\
--data "client_id=XXXX_[...]"\
--data "client_assertion_type=urn:ietf:params:oauth:client-assertion-type:jwt-bearer"\
--data "client_assertion=long string [...]"

20
scripts/make-jwt.py Normal file
View File

@ -0,0 +1,20 @@
from cryptography.hazmat.primitives import serialization
from cryptography.hazmat.backends import default_backend
from json import load
import jwt
PRIVATE_KEY = "pkcs8privatekey.pem"
PAYLOAD = "jwt"
with open(PRIVATE_KEY, "rb") as f:
pem_bytes = f.read()
with open(PAYLOAD, "rb") as f:
payload = load(f)
print(pem_bytes)
print(payload)
private_key = serialization.load_pem_private_key(pem_bytes, password=None, backend=default_backend())
encoded = jwt.encode(payload, private_key, algorithm="RS256")
print(encoded)

7
scripts/refresh-token.sh Executable file
View File

@ -0,0 +1,7 @@
curl https://sandbox-b2b.revolut.com/api/1.0/auth/token \
-H "Content-Type: application/x-www-form-urlencoded"\
--data "grant_type=refresh_token"\
--data "refresh_token=oa_sand_[...]"\
--data "client_id=XXXX_[...]"\
--data "client_assertion_type=urn:ietf:params:oauth:client-assertion-type:jwt-bearer"\
--data "client_assertion=long string [...]"