If your new application is receiving '401 unauthorized' errors when making requests to the Pushwoosh API (such as for registerDevice
, getInApps
, etc.), it typically means there's an authentication problem with your Pushwoosh Application Code (APPID) or, more commonly, the Device API Token.
Here’s how to troubleshoot and resolve this:
Verify API Token Configuration:
- Ensure you have correctly set the
Pushwoosh_APPID
(your Pushwoosh Application Code) in your application's configuration. - Crucially, ensure you are using the Device API Token for the
Pushwoosh_API_TOKEN
setting in your app (e.g., in theInfo.plist
file for iOS, or equivalent for other platforms). Using a Server API Token on the client-side will cause this error. - You can find your Pushwoosh Application Code and generate/manage Device API Tokens in your Pushwoosh Control Panel.
- Ensure you have correctly set the
Authorize New Application for Existing Token:
- If you are using an existing Device API Token for your new application, it might not be automatically authorized to use this token. For security, new applications often need to be manually associated with an existing token.
- How to fix:
- Log in to your Pushwoosh Control Panel.
- Navigate to the 'API Access' section (or similar, depending on your Control Panel version).
- Find the Device API Token you intend to use with your new application.
- Check if your new application (identified by its Application Code) is listed and enabled/authorized for this token.
- If it's not listed or not enabled, you will need to add or enable your new application for that specific Device API Token. The interface may allow you to select which applications are permitted to use the token.
Alternative: Create a New Device API Token:
- You can create a new Device API Token specifically for your new application. When a new token is generated, it is typically configured to work with the intended application, which can avoid the manual authorization step required for reusing existing tokens.
Example Configuration (iOS Info.plist
):
<key>Pushwoosh_APPID</key>
<string>YOUR_PUSHWOOSH_APPLICATION_CODE</string>
<key>Pushwoosh_API_TOKEN</key>
<string>YOUR_DEVICE_API_TOKEN</string>
Replace YOUR_PUSHWOOSH_APPLICATION_CODE
and YOUR_DEVICE_API_TOKEN
with your actual values from the Pushwoosh Control Panel.
By ensuring the correct Device API Token is used and that your new application is authorized to use it, you should be able to resolve the '401 unauthorized' errors.
Comments
0 comments
Please sign in to leave a comment.