feat: write access token to json file

This commit is contained in:
Aravinth Manivannan 2023-09-18 17:55:18 +05:30
parent f4002b6a46
commit 9c96169b3d
Signed by: realaravinth
GPG key ID: F8F50389936984FF
2 changed files with 5 additions and 2 deletions

View file

@ -1,5 +1,6 @@
import os import os
import random import random
import json
from urllib.parse import urlunparse, urlparse from urllib.parse import urlunparse, urlparse
from html.parser import HTMLParser from html.parser import HTMLParser
from time import sleep from time import sleep
@ -293,5 +294,6 @@ class Forgejo:
print("Created access token") print("Created access token")
data = resp.json() data = resp.json()
with open(file, "w") as f: with open(file, "w") as f:
f.write(f"{data['sha1']}") content = json.dumps(data)
f.write(content)
print(f"Wrote access token to {file}") print(f"Wrote access token to {file}")

View file

@ -25,7 +25,8 @@ readonly FORGEJO_USER1_PASSWORD=supercomplicatedpassword
readonly FORGEJO_USER1_EMAIL="$FORGEJO_USER1_USERNAME@example.org" readonly FORGEJO_USER1_EMAIL="$FORGEJO_USER1_USERNAME@example.org"
readonly FORGEJO_USER1_SUPPORT_REPO="support" readonly FORGEJO_USER1_SUPPORT_REPO="support"
readonly FORGEJO_USER1_ACCESS_TOKEN_NAME="coreaccesstoken" readonly FORGEJO_USER1_ACCESS_TOKEN_NAME="coreaccesstoken"
readonly FORGEJO_USER1_ACCESS_TOKEN_FILE_PATH=$(realpath secrets/user1-accesstoken) readonly FORGEJO_USER1_ACCESS_TOKEN_FILE_PATH=$(realpath secrets/user1-accesstoken.json)
rm $FORGEJO_USER1_ACCESS_TOKEN_FILE_PATH || true
readonly FORGEJO_TESTUSER_USERNAME=test_user readonly FORGEJO_TESTUSER_USERNAME=test_user
readonly FORGEJO_TESTUSER_PASSWORD=supercomplicatedpassword readonly FORGEJO_TESTUSER_PASSWORD=supercomplicatedpassword