54 lines
1.5 KiB
Python
54 lines
1.5 KiB
Python
import requests
|
|
|
|
|
|
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",
|
|
},
|
|
"group_id": 461982,
|
|
"complete": True,
|
|
"private": False,
|
|
},
|
|
}
|
|
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()
|