Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class HasuraTokenInterceptor implements Interceptor {
- @Override
- public Response intercept(Chain chain) throws IOException {
- Request request = chain.request();
- Response response;
- String session = Hasura.getUserSessionId();
- if (session == null) {
- response = chain.proceed(request);
- } else {
- Request newRequest = request.newBuilder()
- .addHeader("Authorization", "Bearer " + session)
- .build();
- response = chain.proceed(newRequest);
- }
- return response;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement