Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cookies are either not persisting, or not being sent out #55

Open
ExciteM-Blog opened this issue Sep 8, 2018 · 1 comment
Open

Cookies are either not persisting, or not being sent out #55

ExciteM-Blog opened this issue Sep 8, 2018 · 1 comment

Comments

@ExciteM-Blog
Copy link

Hi,

We are using this library with OkHttp3 in 2 separate activities.
In the first activity, we are logging in via a POST, and then starting the second activity.
Once there, we request some information to the same server via a GET call (this is a secured endpoint).
This second call is failing saying the request is not authorized.
This system has been on production for years, so we know it's not the issue.

It looks like either the cookies are not being saved on the initial POST response, or sent out on the GET call. I was under the impression they are saved and sent out by this library, is there something extra that needs to be done?

Here's how we're setting up the client (in both activites):

// Have also tried ClearableCookieJar instead of CookieJar
CookieJar cookieJar =
     new PersistentCookieJar(new SetCookieCache(), new SharedPrefsCookiePersistor(this));

OkHttpClient client = new OkHttpClient.Builder()
     .cookieJar(cookieJar)
     .build();
@ExciteM-Blog ExciteM-Blog changed the title Cookies are either not persisting, or being sent out Cookies are either not persisting, or not being sent out Sep 8, 2018
@ezamelczykespeo
Copy link

You need to share the OkHttpClient instance between the activities.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants