"401 Unauthorized" error message usually occurs, when the device-type API token:
1. Isn't added to the application's config (AndroidManifest.xml for Android and info.plist for iOS)
2. Has incorrect type. For example, server-type is used instead of the device-type token
3. Lacks app permissions
To fix the issue:
1. Create a device-type API token in Pushwoosh control panel (select an application and go to "Settings" -> "API Access")
2. Make sure that the token has permission to your app:
3. Add the token to the configuration of the app:
Android: AndroidManifest.xml file:
<meta-data android:name="com.pushwoosh.apitoken" android:value="__YOUR_DEVICE_TYPE_API_TOKEN_FROM_PW_CONTROL_PANEL_" />
iOS: info.plist:
<key>Pushwoosh_API_TOKEN</key>
<string>__YOUR_DEVICE_TYPE_API_TOKEN_FROM_PW_CONTROL_PANEL_</string>
Example error log:
2025-05-06 08:49:12.863 5743-5822 Pushwoosh com.pushwoosh.demoapp E [RequestManager] ERROR: {"status_code":401,"status_message":"Unauthorized"}
com.pushwoosh.internal.network.NetworkException: {"status_code":401,"status_message":"Unauthorized"}
at com.pushwoosh.internal.network.c.a(SourceFile:8)
at com.pushwoosh.internal.network.c.a(SourceFile:1)
at com.pushwoosh.internal.network.c$b.a(SourceFile:1)
at com.pushwoosh.internal.network.c$b.doInBackground(Unknown Source:2)
at android.os.AsyncTask$3.call(AsyncTask.java:394)
at java.util.concurrent.FutureTask.run(FutureTask.java:264)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:305)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:644)
at java.lang.Thread.run(Thread.java:1012)
2025-05-06 08:49:12.863 5743-5743 Pushwoosh
Comments
0 comments
Please sign in to leave a comment.