If your iOS application is encountering '401 unauthorized' errors when making requests to the Pushwoosh API (such as registerDevice
, getInApps
, registerUser
, etc.), it typically indicates an issue with your API token configuration or the authorization of your application to use that token.
Here's how to troubleshoot and resolve this:
-
Verify
Info.plist
Configuration:- Ensure you are using the correct Pushwoosh Application Code and the Device API Token (not the Server API Token) in your application's
Info.plist
file. - The keys should be set as follows:
-
Pushwoosh_APPID
: Your Pushwoosh Application Code. -
Pushwoosh_API_TOKEN
: Your Pushwoosh Device API Token.
-
- You can find your Application Code and generate/find your Device API Token in your Pushwoosh Control Panel (usually under an "API Access" or similar section).
Example
Info.plist
entries:<key>Pushwoosh_APPID</key> <string>YOUR_PUSHWOOSH_APP_CODE</string> <key>Pushwoosh_API_TOKEN</key> <string>YOUR_DEVICE_API_TOKEN</string>
For more details on basic SDK setup, refer to the Pushwoosh iOS SDK Integration Guide.
- Ensure you are using the correct Pushwoosh Application Code and the Device API Token (not the Server API Token) in your application's
-
Authorize Your Application for the API Token:
- A common reason for '401 unauthorized' errors, even with the correct token in
Info.plist
, is that the specific application (also referred to as a project within Pushwoosh) has not been authorized to use that Device API Token. - By default, for security purposes, new applications may need to be manually associated with or authorized for an existing Device API Token.
- Check your Pushwoosh Control Panel settings (often on the "API Access" page where tokens are managed) to ensure your application is listed or enabled for the Device API Token you are using.
- If you cannot find this option or are unsure, you may need to contact Pushwoosh support to assist with authorizing the application for your token.
- A common reason for '401 unauthorized' errors, even with the correct token in
-
Consider a Dedicated API Token for New Apps:
- As an alternative to authorizing an existing token for a new app, you can create a new, dedicated Device API Token specifically for each new application. This can sometimes simplify token management and permissions.
If you have verified these steps and the '401 unauthorized' error persists, double-check your complete Pushwoosh SDK integration against the official documentation and ensure there are no other typos or configuration issues in your project.
Comments
0 comments
Please sign in to leave a comment.