Search code examples
android-studiokotlinpush-notificationpusherandroid-push-notification

Could not set user id, jwt rejected: Forbidden: Invalid JWT issuer


I have used Pusher Beams in my app, it has worked great till 2 days ago. It has stopped with this error:

Could not set user id, jwt rejected: Forbidden: Invalid JWT issuer

Any idea how to solve this? and is it related to server side or is in the android?

 fun setPusherBeam(userId: String){

     PushNotifications.start(context, BuildConfig.INSTANCE_ID)

     val tokenProvider = BeamsTokenProvider(
                    BuildConfig.PUSHER_BEAM,
                    object : AuthDataGetter {
                        override fun getAuthData(): AuthData {
                            return AuthData(
                                headers = hashMapOf(
                                    "Authorization" to auth_token_key)

                                ),
                                queryParams = hashMapOf()
                            )
                        }
                    }
                )

               

                PushNotifications.setUserId(
                    userId,
                    tokenProvider,
                    object : BeamsCallback<Void, PusherCallbackError> {
                        override fun onFailure(error: PusherCallbackError) {
                            Timber.d("Beams login failed: ${error.message}")
                        }

                        override fun onSuccess(vararg values: Void) {
                            Timber.d("Beams login success ")
                        }
                    }
                )

            } catch (ex: Exception) {
                Timber.d("Beams ex ${ex.localizedMessage}")
            }
        }
}

Solution

  • It seems that your jwt token doesn't have the same issuer claim anymore so your token provider, PusherBeam in this case, can't validate the token and because of that it fails.

    To check if anything of your token has changed, you can go to https://jwt.io website, paste your jwt token, and see if the iss claim (issuer) has a value different from the one your token provided expects. If this is not the problem you should check the other claims also (exp to be sure that the token is not expired, aud to be sure that contains the service that must recieve the token... ) But reading the error the problem must be with the iss claim