question

Yun Sun avatar image
Yun Sun asked

Amazon Music API with LWA on iOS?

How can I use LWS iOS for Amazon Music API?

While calling a music API(for ex, https://dashboard.music.amazon.dev/api/#operation/get-album), I am getting 401 - ACCESS_DENIED error when I try to use the token from LWS iOS.

login with amazoniosamazon music
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

Atif Nawaz avatar image
Atif Nawaz answered

The "LWS iOS" you're referring to might be "Login with Amazon" (LWA) SDK for iOS. If you're encountering a 401 "ACCESS_DENIED" error while using the LWA token to access the Amazon Music API, there could be a few reasons for this issue. Here are some troubleshooting steps you can take:

  1. Token Verification: Ensure that the LWA token you're obtaining is valid and properly authorized. Make sure the token is generated using the correct client ID and scope for accessing the Amazon Music API. You can verify the token's content using tools like JWT.io.

  2. Scope Permissions: Check that the scope requested when obtaining the LWA token includes the necessary permissions to access the Amazon Music API. If your token doesn't have the required scope, you might not have the necessary permissions to make the API calls.

  3. API Endpoint and Headers: Double-check that you're making the API request to the correct endpoint (e.g., https://api.music.amazon.com/...). Ensure that you're including the necessary headers in your API request, such as the "Authorization" header with the "Bearer" token.

  4. CORS: Cross-Origin Resource Sharing (CORS) might be an issue if you're making requests from a web app or a mobile app using a web view. Make sure that the API server allows requests from your domain or app.

  5. Token Expiry: Verify the expiration time of the LWA token. Tokens have a limited validity period. If the token has expired, you'll need to refresh it using the token refresh flow provided by LWA.

  6. Rate Limiting: Some APIs impose rate limits to prevent abuse. Ensure that you're not hitting rate limits by making too many requests in a short period of time.

  7. Error Handling: The 401 "ACCESS_DENIED" error might be accompanied by additional error information in the response body. Check the error message or code to get more details on what's causing the denial of access.

  8. Developer Console Configuration: Check your developer console settings for both LWA and the Amazon Music API. Make sure that your app is correctly configured with the right permissions and domains.

  9. Support Documentation and Forums: Consult the official documentation for the Amazon Music API and the LWA SDK for iOS. You can also visit developer forums to see if others have encountered similar issues and find potential solutions.

  10. Contact Support: If you've exhausted your troubleshooting options and the issue persists, consider reaching out to Amazon's developer support for assistance. They can provide more specific guidance based on your integration and setup.

Keep in mind that APIs, SDKs, and integration points can change over time, so always refer to the most current documentation and resources for accurate information.

10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.