API Gitea: token 2

This commit is contained in:
parent 64858bab2b
commit 8807a7650c

33
API Gitea/Gitea2.py Normal file
View File

@ -0,0 +1,33 @@
import requests
import os
from dotenv import load_dotenv
load_dotenv()
TOKEN = os.getenv("GITEA_TOKEN2")
headers = {
"Authorization": f"token {TOKEN}",
"Content-Type": "application/json"
}
# Эндпоинт для изменения своих настроек
profile_data = {
"full_name": "Александр Костюкин (изменено через API)",
"description": "Мой профиль, который я поменял через API Gitea",
"language": "ru-ru",
"website": "https://git.vyatsu.ru/stud203797",
"location": "Киров, Россия"
}
response = requests.patch(
"https://git.vyatsu.ru/api/v1/user/settings",
headers=headers,
json=profile_data
)
print(f"Status: {response.status_code}")
if response.status_code == 200:
print("Profile updated successfully")
print(response.json())
else:
print(f"Error: {response.text}")