I have created a smart home alexa skill using aws lamdba. Given all the permission required to access the information of the user. Still not able to resolve the Access Denied issue.
Trying to access user email using the below code in python:
def user_email(access_token):
try:
# API endpoint URL
url = “https://api.eu.amazonalexa.com/v2/accounts/~current/settings/Profile.email”
#url = “https://api.amazonalexa.com/v2/accounts/~current/settings/Profile.email”
headers = {
“Authorization”: f”Bearer {access_token}”,
“Content-Type”: “application/json”,
“Accept”: “application/json”
}
response = requests.get(url, headers=headers)
if response.status_code == 200:
email = response.json().get(“email”)
return email
else:
print(f”Error: {response.status_code} – {response.text}”)
return None
except Exception as e:
print(str(e))
Getting the below error in response to above code:
response:
Error: 403 –
{
“code”: “ACCESS_DENIED”,
“message”: “Consent token in request does not have access to resource requested”
}
I changed the scope from profile to alexa::profile:email:read and added custom model using which I have enable the user consent to send their email address.
Ashish Agarwal is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.