I am experimenting with the new Location Services feature that was announced yesterday. I have a SKill in development that already uses the country and postal code information so adding Location Services was easy. However, I have run into a problem checking for permissions due to an inconsistency in how permissions are validated. Previously, using examples posted by Amazon on GitHub, one would check for permissions as follows
const PERMISSIONS = ["alexa:device:all:address:country_and_postal_code:read"]; const accessToken = requestEnvelope.context.System.user.permissions && requestEnvelope.context.System.apiAccessToken; if (!accessToken) { return responseBuilder .speak("Please open the Alexa application and grant this Skill permission to access your location information.") .withAskForPermissionsConsentCard(PERMISSIONS) .getResponse(); }
However, with the new Location Services permission, this test no longer works. Now "requestEnvelope.context.System.user.permissions" is always defined if Location Services permission is requested by the Skill. Even if no permissions are granted by the user which in the past would cause the test in the code above to work. This is due to a new key of 'requestEnvelope.context.System.user.permissions.scopes["alexa::devices:all:geolocation:read"]' being defined with a property of "status". "status" is either "DENIED" or "GRANTED". This is all fine EXCEPT there is no corresponding key for the "read::alexa:device:all:address:country_and_postal_code" permission or possibly any other permission. So I have no reliable way to check for that permission being "GRANTED" or "DENIED". A simple check for the presence of "requestEnvelope.context.System.user.permissions" is no longer sufficient to determine whether or not "read::alexa:device:all:address:country_and_postal_code" is granted.
It would be nice to get some consistency in the permissions check behavior. Either provide the granted/denied status of all the requested permissions or go back to having permission undefined. Personally I prefer the former as knowing which permission may not have been granted is more helpful.