0

I'm writing in Go and testing an Alexa skill and looking to retrieve the user's Amazon account name and other fields. I have the permissions set correctly in the alexa developer console. I have ALL of the permissions enabled.

My functions are running in AWS Lambda and Alexa tests just fine with other functions.

Here is the code:

func callAmazonAPI(apiEndpoint string, apiToken string) (string, error) {
    //url := apiEndpoint + "/v2/accounts/~current/settings/Profile.name"
    url := "https://api.amazonalexa.com/v2/accounts/~current/settings/Profile.name"

    // Create a Bearer string by appending string access token
    var bearer = "Bearer " + apiToken

    // Create a new request using http
    req, err := http.NewRequest("GET", url, nil)

    req.Header.Add("Authorization", bearer)
    req.Header.Add("Accept", "application/json")
    req.Header.Add("Host", "api.amazonalexa.com")

    // Send req using http Client
    client := &http.Client{}
    resp, err := client.Do(req)
    if err != nil {
        return "Error in callAMazonAPI!", err
    }

    body, _ := ioutil.ReadAll(resp.Body)
    return string([]byte(body)), err
}

It is not returning an error. It is returning this:

{"code":"ACCESS_DENIED","message":"Access denied with reason: ACCESS_NOT_REQUESTED"}

According to the Alexa documentation I should have access to account information.

  • 1
    Just because you define you want those permissions in the Alexa console, doesn't mean the user has actually granted those permissions to you. You need to actually request them from the user with a permissions card which they then need to accept and then use the api to make the request. https://developer.amazon.com/en-US/docs/alexa/custom-skills/request-customer-contact-information-for-use-in-your-skill.html The code you've provided is just trying to access the API, I don't see where you've asked the customer for permission – TommyBs Jan 29 '20 at 06:40
  • I'm only testing in the Alexa console. In reading the help it sounds like in testing the console you have the permission granted. Is that not the case? – Wes Skorski Jan 30 '20 at 10:51
  • I’m not 100% sure but I know some permissions actively don’t work at all in the test console – TommyBs Jan 30 '20 at 10:52

0 Answers0