Search code examples
swiftalexa-skills-kitlogin-with-amazon

SMAPI Alexa Read Scope in Swift


I'm trying to get read & write permissions, so users can see their alexa skill from an ios app.

I successfully managed to let the user sign in with their amazon account (via the LWA iOS SDK). When I add the profile scope to the authentication process I get this error when trying to make a get request to the skill endpoint:

"User has not consented to this operation."

So I added the alexa::ask scope, so I get the right permissions:

let scopeData_alexa: [AnyHashable:Any] = ["productID" : AmazonManager.shared.productId, "productInstanceAttributes": [ "deviceSerialNumber": uniqueDeviceSerialNumber]]

let readPermissions = AMZNScopeFactory.scope(withName: "alexa::ask:skills:readwrite", data: scopeData_alexa)

When I try to authenticate the user I get this response:

Error Domain=AMZNLWAErrorDomain Code=2 "(null)" UserInfo={AMZNLWAErrorNonLocalizedDescription=The+scope+data+list+you+provided+is+invalid+for+your+request}

As said above, the normal login works fine. The scope Data is also working, when I ask the user for Alexa Voice Services.

What to I have to change? Any solutions?


Solution

  • It was super easy to fix.

    just remove the data parameter

    let readPermissions = AMZNScopeFactory.scope(withName: "alexa::ask:skills:readwrite")
    

    Then it should work fine!