alexa-samples / alexa-smarthome

Resources for Alexa Smart Home developers.
https://alexa.design/smarthome
Other
679 stars 336 forks source link

Unable to get Access token using authorization code for a skill in lambda function #168

Closed deekshith-elear closed 9 months ago

deekshith-elear commented 3 years ago

Hi, I have successfully enabled send alexa event permission and got client_id and secret. I had received an authgrant request which contains an authorization code for my lambda function. from there I'm trying to get an access token using https://api.amazon.com/auth/o2/token Getting below error

    "statusCode": 500,
    "body": {},
    "headers": {
        "server": "Server",
        "date": "Fri, 20 Nov 2020 03:37:03 GMT",
        "content-type": "application/json;charset=UTF-8",
        "content-length": "2",
        "connection": "close",
        "x-amz-rid": "REBDS5MD3K1X1F6TPTC3",
        "x-amzn-requestid": "24855146-25ed-4e0a-8393-8802e776bc88",
        "x-amz-date": "Fri, 20 Nov 2020 03:37:03 GMT",
        "x-amzn-errortype": "InternalFailure:http://internal.amazon.com/coral/com.amazon.coral.service/",
        "cache-control": "no-cache, no-store, must-revalidate",
        "pragma": "no-cache",
        "vary": "Content-Type,Accept-Encoding,X-Amzn-CDN-Cache,X-Amzn-AX-Treatment,User-Agent"
    },
    "request": {
        "uri": {
            "protocol": "https:",
            "slashes": true,
            "auth": null,
            "host": "api.amazon.com",
            "port": 443,
            "hostname": "api.amazon.com",
            "hash": null,
            "search": "?grant_type=authorization_code&code=RHpeYchXfMSMpbUJJYSR&client_id=amzn1.application-oa2-client.40acc86a12a2448cbe29311c6045f3ca&client_secret=",
            "query": "grant_type=authorization_code&code=RHpeYchXfMSMpbUJJYSR&client_id=amzn1.application-oa2-client.40acc86a12a2448cbe29311c6045f3ca&client_secret=",
            "pathname": "/auth/o2/token",
            "path": "/auth/o2/token?grant_type=authorization_code&code=RHpeYchXfMSMpbUJJYSR&client_id=amzn1.application-oa2-client.40acc86a12a2448cbe29311c6045f3ca&client_secret=",
            "href": "https://api.amazon.com/auth/o2/token?grant_type=authorization_code&code=RHpeYchXfMSMpbUJJYSR&client_id=amzn1.application-oa2-client.40acc86a12a2448cbe29311c6045f3ca&client_secret="
        },
        "method": "POST",
        "headers": {
            "Content-Type": "application/x-www-form-urlencoded;charset=UTF-8",
            "accept": "application/json",
            "content-length": 0
        }
    }
}

while referring amazon documentation when we enable send alexa permission a security profile will be created in developer console but, I'm not able to see in my console Reference: https://developer.amazon.com/en-US/docs/alexa/smarthome/authenticate-a-customer-permissions.html Is there any change in the process?

duncmac16 commented 3 years ago

@deekshith-elear Any update on how you resolved this?

TriTerra003 commented 3 years ago

Hi, do you have any updates on solving this? I am having the same problem recently. I have enabled the push event permission and do not see any change in the security profile. I send the code to the amazon token endpoint and keep receiving 500 response.

aszk commented 9 months ago

If you have difficulty retrieving accessToken and refreshToken, please use https://alexa.design/contactus for help.

Please do not share your client secret to public.