Advertisement
Guest User

Untitled

a guest
Jan 24th, 2017
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. public class HasuraTokenInterceptor implements Interceptor {
  2. @Override
  3. public Response intercept(Chain chain) throws IOException {
  4. Request request = chain.request();
  5. Response response;
  6. String session = Hasura.getUserSessionId();
  7. if (session == null) {
  8. response = chain.proceed(request);
  9. } else {
  10. Request newRequest = request.newBuilder()
  11. .addHeader("Authorization", "Bearer " + session)
  12. .build();
  13. response = chain.proceed(newRequest);
  14. }
  15. return response;
  16. }
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement