github GetStream/stream-chat-android 2.1.0
Token Renewal Flow

latest releases: 6.30.0, 6.29.0, 6.28.0...
6 years ago

Simplifies the flow of regenerating expired JWT tokens.

client.setUser(user, listener -> {
            OkHttpClient httpClient = new OkHttpClient()
                    .newBuilder()
                    .build();

            // request the token for this user
            Request request = new Request.Builder()
                    .url("https://path/to/my/backend/")
                    .header("Authorization", "user-session-id")
                    .build();

            httpClient.newCall(request).enqueue(new Callback() {
                @Override
                public void onFailure(@NotNull Call call, @NotNull IOException e) {
                    // the request to get the token failed
                }

                @Override
                public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException {
                    Log.w(TAG, "getting the token worked!");
                    listener.onSuccess(response.body.string());
                }
            });
        }
);

Don't miss a new stream-chat-android release

NewReleases is sending notifications on new releases.