postaddictme / instagram-java-scraper

Instagram Java Scraper. Get account information, photos, videos and comments.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Login Access denied

ffurkanhas opened this issue · comments

I want to login like that:

HttpLoggingInterceptor loggingInterceptor = new HttpLoggingInterceptor();
loggingInterceptor.setLevel(HttpLoggingInterceptor.Level.BODY);

    OkHttpClient httpClient = new OkHttpClient.Builder()
            .addNetworkInterceptor(loggingInterceptor)
            .addInterceptor(new ErrorInterceptor())
            .cookieJar(new DefaultCookieJar(new CookieHashSet()))
            .build();

    Instagram instagram = new Instagram(httpClient);
    instagram.login("my_username","my_password");

Exception in thread "main" me.postaddict.instagram.scraper.exception.InstagramAuthException: Access denied
at me.postaddict.instagram.scraper.interceptor.ErrorInterceptor.intercept(ErrorInterceptor.java:27)
at okhttp3.RealCall$ApplicationInterceptorChain.proceed(RealCall.java:187)
at okhttp3.RealCall.getResponseWithInterceptorChain(RealCall.java:160)
at okhttp3.RealCall.execute(RealCall.java:57)
at me.postaddict.instagram.scraper.Instagram.executeHttpRequest(Instagram.java:274)
at me.postaddict.instagram.scraper.Instagram.login(Instagram.java:65)
at service.InstagramConnector.scrapperConnect(InstagramConnector.java:24)
at App.main(App.java:11)

    HttpLoggingInterceptor loggingInterceptor = new HttpLoggingInterceptor();
    loggingInterceptor.setLevel(HttpLoggingInterceptor.Level.BODY);

    OkHttpClient httpClient = new OkHttpClient.Builder()
            .addNetworkInterceptor(loggingInterceptor)
            .addInterceptor(new ErrorInterceptor())
            .cookieJar(new DefaultCookieJar(new CookieHashSet()))
            .build();


    Instagram instagram = new Instagram(httpClient);
    Account account = instagram.getAccountByUsername("kevin");
    System.out.println(account.getMedia().getCount());

Have the same issue
--> GET https://www.instagram.com/kevin/?__a=1 http/1.1
Host: www.instagram.com
Connection: Keep-Alive
Accept-Encoding: gzip
User-Agent: okhttp/3.2.0
--> END GET
<-- 403 Forbidden https://www.instagram.com/kevin/?__a=1 (153ms)
Content-Type: text/html; charset=utf-8
x-robots-tag: noindex
Cache-Control: private, no-cache, no-store, must-revalidate
Pragma: no-cache
Expires: Sat, 01 Jan 2000 00:00:00 GMT
Vary: Accept-Language, Cookie
Content-Language: en
Date: Fri, 26 Oct 2018 09:46:33 GMT
Strict-Transport-Security: max-age=60
X-Frame-Options: SAMEORIGIN
content-security-policy: report-uri https://www.instagram.com/security/csp_report/; default-src 'self' https://www.instagram.com; img-src https: data: blob:; font-src https: data:; media-src 'self' blob: https://www.instagram.com https://.cdninstagram.com https://.fbcdn.net; manifest-src 'self' https://www.instagram.com; script-src 'self' https://instagram.com https://www.instagram.com https://.www.instagram.com https://.cdninstagram.com wss://www.instagram.com https://.facebook.com https://.fbcdn.net https://.facebook.net 'unsafe-inline' 'unsafe-eval' blob:; style-src 'self' https://.www.instagram.com https://www.instagram.com 'unsafe-inline'; connect-src 'self' https://instagram.com https://www.instagram.com https://.www.instagram.com https://graph.instagram.com https://.graph.instagram.com https://.cdninstagram.com https://api.instagram.com wss://www.instagram.com wss://edge-chat.instagram.com https://.facebook.com https://.fbcdn.net https://.facebook.net chrome-extension://boadgeojelhgndaghljhdicfkmllpafd; worker-src 'self' https://www.instagram.com; frame-src 'self' https://instagram.com https://www.instagram.com https://staticxx.facebook.com https://www.facebook.com https://web.facebook.com https://connect.facebook.net https://m.facebook.com; object-src 'none'; upgrade-insecure-requests
X-XSS-Protection: 0
Set-Cookie: mid=W9LieQAEAAE-_piDXPCH4GjD1k-J; Domain=.instagram.com; expires=Mon, 23-Oct-2028 09:46:33 GMT; Max-Age=315360000; Path=/; Secure
Set-Cookie: rur=FRC; Domain=.instagram.com; HttpOnly; Path=/; Secure
Set-Cookie: mcd=3; Domain=.instagram.com; expires=Mon, 23-Oct-2028 09:46:33 GMT; Max-Age=315360000; Path=/; Secure
Set-Cookie: csrftoken=PmmF2UfTDCh9VObl9in4hXOoxbOcBASV; Domain=.instagram.com; expires=Fri, 25-Oct-2019 09:46:33 GMT; Max-Age=31449600; Path=/; Secure
Connection: keep-alive
Content-Length: 0
OkHttp-Sent-Millis: 1540547193199
OkHttp-Received-Millis: 1540547193350
<-- END HTTP (0-byte body)
Exception in thread "main" me.postaddict.instagram.scraper.exception.InstagramAuthException: Access denied
at me.postaddict.instagram.scraper.interceptor.ErrorInterceptor.intercept(ErrorInterceptor.java:27)
at okhttp3.RealCall$ApplicationInterceptorChain.proceed(RealCall.java:187)
at okhttp3.RealCall.getResponseWithInterceptorChain(RealCall.java:160)
at okhttp3.RealCall.execute(RealCall.java:57)
at me.postaddict.instagram.scraper.Instagram.executeHttpRequest(Instagram.java:285)
at me.postaddict.instagram.scraper.Instagram.getAccountByUsername(Instagram.java:91)
at Main.main(Main.java:28)

Process finished with exit code 1

I'm facing "private mode error".

<p>This page could not be loaded. If you have cookies disabled in your browser, or you are browsing in Private Mode, please try enabling cookies or turning off Private Mode, and then retrying your action.</p>