ARTICLE AD BOX
I have written a simple Alexa skill which works and I've now added a Widget, these both display as expected.
I am now trying to use the datastore but every time I try to update the store, I am getting an error related to not being able to find the Client ID from the skill metadata.
I am using the ClientID & Client Secret from the Permissions section of the skill in the Alexa Developer Console, using this and the alexa::datastore scope, I am able to authorize and get an access_token.
However, when I the try to call the Data Store REST API to update the datastore, it fails with the following error:
{ "type": "INVALID_ACCESS_TOKEN", "message": "Unable to find the Client ID from skill metadata:amzn1.application-oa2-client.xxxxxxxxx" }I have tried running the Plant Care Widget example skill as it uses the datastore, but that also returns the same error if I look in the CloudWatch Logs.
I have spent a couple of days trying to get this working to no avail.
I am sure my ClientID & Client Secret's are correct, as the authorization works, so it feels like its either some other configuration issue, or a platform issue, or maybe I missed a step that is required?
I also wrote a quick Powershell script to test the API which you can see below:
$clientId = "your-client-id" $clientSecret = "your-secret" $body = @{ grant_type = "client_credentials" client_id = $clientId client_secret = $clientSecret scope = "alexa::datastore" } $tokenResponse = Invoke-RestMethod ` -Uri "https://api.amazon.com/auth/o2/token" ` -Method Post ` -ContentType "application/x-www-form-urlencoded" ` -Body $body $tokenResponse | Format-List * $accessToken = $tokenResponse.access_token $accessToken $headers = @{ Authorization = "Bearer $accessToken" "Content-Type" = "application/json" "Charset" = "utf-8" } $timestamp = (Get-Date).ToUniversalTime().ToString("o") $payloadObject = @{ commands = @( @{ type = "WRITE" namespace = "debug" key = "ping" data = @{ ts = $timestamp } } ) target = @{ type = "USERS" users = @( @{ userId = "dummy-user" } ) } } $payloadJson = $payloadObject | ConvertTo-Json -Depth 10 $response = Invoke-WebRequest ` -Uri "https://api.amazonalexa.com/v1/datastore/commands" ` -Method Post ` -Headers $headers ` -Body $payloadJson $response.StatusCode $response.ContentAny help you can give will be much appreciated!
