instagram-java-scraper icon indicating copy to clipboard operation
instagram-java-scraper copied to clipboard

Can't login. Get http status 400

Open tpraizler opened this issue 8 years ago • 1 comments

Hey,

I am not sure it's a problem in the lib, but I try to login in the recent days and fail.

  val httpClient: OkHttpClient =
  new OkHttpClient.Builder()
    .addInterceptor(new UserAgentInterceptor(UserAgents.OSX_CHROME))
    .addInterceptor(new ErrorInterceptor)
    .cookieJar(new DefaultCookieJar(new CookieHashSet))
    .build

  val client = new Instagram(httpClient)

  def login(): Unit = {
    client.basePage()
    client.login(credentials.username, credentials.password)
    client.basePage()
  }

I am using the same code to do this locally and I manage to log in, but once I upload this code to my server which is not where I am located it fails. Do you have any suggestions on how to handle this?

tpraizler avatar Jan 14 '18 21:01 tpraizler

Hi @tpraizler Try add logging interceptor and collect more context info:

        HttpLoggingInterceptor loggingInterceptor = new HttpLoggingInterceptor();
        loggingInterceptor.setLevel(HttpLoggingInterceptor.Level.BODY);
        OkHttpClient httpClient = new OkHttpClient.Builder()
.addNetworkInterceptor(loggingInterceptor)

igor-suhorukov avatar Jan 15 '18 07:01 igor-suhorukov