I have followed the steps in this tutorial: https://learn.microsoft.com/en-us/azure/active-directory-b2c/identity-provider-apple-id?pivots=b2c-custom-policy to create an Apple sign in for my application. From the Apple Developer Portal menu, I went to Certificates, IDs, & Profiles and created a Key. I then tried to sign the key be using this python script:
import jwt
import time
def generate_token():
private_key = """[pasted key from Apple here]"""
team_id = "[pasted team_id]"
client_id = "[pasted client_id]"
key_id = "[pasted key_id]"
validity_minutes = 20
timestamp_now = int(time.time())
timestamp_exp = timestamp_now + (60 * validity_minutes)
data = {
"iss": team_id,
"iat": timestamp_now,
"exp": timestamp_exp,
"aud": "https://appleid.apple.com",
"sub": client_id
}
token = jwt.encode(
payload=data,
key=private_key, # Use the key directly without encoding as 'utf-8', jwt.encode handles this.
algorithm="ES256",
headers={"kid": key_id}
)
print(token)
generate_token()
I don't think this worked because I am getting an error after I sign in. Is there some other script I can use?