2023-06-07 22:10:31 -04:00
|
|
|
import requests
|
|
|
|
|
|
2023-06-08 16:53:46 -04:00
|
|
|
|
|
|
|
|
def create_cred():
|
|
|
|
|
url = "https://api.accredible.com/v1/credentials"
|
|
|
|
|
headers = {
|
|
|
|
|
"Content-Type": "application/json",
|
|
|
|
|
"Authorization": "Token token=2eb7a23015c751f973ac7db2590bd100",
|
|
|
|
|
}
|
|
|
|
|
payload = {
|
|
|
|
|
"credential": {
|
|
|
|
|
"recipient": {
|
|
|
|
|
"name": "Norm Test",
|
|
|
|
|
"email": "norm+accredtest2@northpass.com",
|
|
|
|
|
# "id": "TEST21234",
|
|
|
|
|
},
|
|
|
|
|
"name": "Skuid Test Credential",
|
|
|
|
|
"group_id": 461982,
|
|
|
|
|
"issued_on": "07/08/2023",
|
|
|
|
|
"expired_on": "07/08/2024",
|
|
|
|
|
"complete": True,
|
|
|
|
|
"private": True,
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
try:
|
|
|
|
|
response = requests.post(url, headers=headers, json=payload)
|
|
|
|
|
text = response.text
|
|
|
|
|
# data = response.json()
|
|
|
|
|
print(f"Text Response: {text}")
|
|
|
|
|
# print(f"Json Response: {data}")
|
|
|
|
|
except TypeError as e:
|
|
|
|
|
print(f"Error! It is {e}")
|
|
|
|
|
finally:
|
|
|
|
|
print("Completed!")
|
|
|
|
|
|
|
|
|
|
# The public URL lives at: https://www.credential.net/013b920d-b7e6-436a-97ae-245e30f916b6
|
|
|
|
|
# Within the payload it is data["credentials"]["url"]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def get_cred():
|
|
|
|
|
url = "https://api.accredible.com/v1/issuer/groups/461982"
|
|
|
|
|
# url = "https://api.accredible.com/v1/credentials"
|
|
|
|
|
headers = {
|
|
|
|
|
"Content-Type": "application/json",
|
|
|
|
|
"Authorization": "Token token=2eb7a23015c751f973ac7db2590bd100",
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
response = requests.get(url, headers=headers)
|
|
|
|
|
text = response.text
|
|
|
|
|
# data = response.json()
|
|
|
|
|
print(f"Text Response: {text}")
|
|
|
|
|
# print(f"Json Response: {data}")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
|
# get_cred()
|
|
|
|
|
create_cred()
|