GithubHelp home page GithubHelp logo

Login Failed, about php-pinterest-bot HOT 29 CLOSED

seregazhuk avatar seregazhuk commented on July 25, 2024
Login Failed,

from php-pinterest-bot.

Comments (29)

seregazhuk avatar seregazhuk commented on July 25, 2024 1

@capripio one more solution. I think it will solve problems with permissions. In file Api/Request.php in constructor change cookieJar for curl:

 /**
     * @param HttpInterface $http
     * @param string|null   $userAgent
     */
    public function __construct(HttpInterface $http, $userAgent = null)
    {
        $this->http = $http;
        if ($userAgent !== null) {
            $this->userAgent = $userAgent;
        }
        // $this->cookieJar = self::COOKIE_NAME; <--- before
        $this->cookieJar = tempnam(sys_get_temp_dir(), self::COOKIE_NAME); // <-- after
    }

from php-pinterest-bot.

seregazhuk avatar seregazhuk commented on July 25, 2024

Hi, I've checked now, everything seems to be working with the latest version, can you show your code?
What is output of print_r($bot->getLastError());?

from php-pinterest-bot.

capripio avatar capripio commented on July 25, 2024

$bot = PinterestBot::create();
$boards = $bot->boards->forUser('USER GOES HERE');
$bot->login('[email protected]', 'passwordGoesHere');
$bot->pins->create($book->img_url, $boards[0]['id'], $desc);

from php-pinterest-bot.

capripio avatar capripio commented on July 25, 2024

I've used it with laravel.

from php-pinterest-bot.

seregazhuk avatar seregazhuk commented on July 25, 2024

Very strange. I've just checked it in Laravel.
As a quick solution you may comment 34 line in /Api/Providers/ProviderLoginCheckWrapper.php and try. I'll continue research for bugs.

from php-pinterest-bot.

capripio avatar capripio commented on July 25, 2024

yes, I did try that, but it doesn't make pin. Let me retry again and update, I've missed something.

from php-pinterest-bot.

capripio avatar capripio commented on July 25, 2024

So I dig deeper in login method, here is the response I get at line 109 in Pinners.php

Might help you

array:5 [▼
"request_identifier" => "224645968114"
"resource_data_cache" => []
"resource" => array:2 [▼
"name" => "UserSessionResource"
"options" => array:3 [▼
"username_or_email" => "EMAIL HERE"
"bookmarks" => array:1 [▼
0 => "-end-"
]
"password" => "PASSWORD HERE"
]
]
"client_context" => array:39 [▼
"origin" => "https://nl.pinterest.com"
"unauth_id" => "89e7c9d2b449458cb3f2ed1bacfa280a"
"is_retina" => false
"user_agent_platform" => "other"
"sterling_admin_mode_view_as" => null
"is_authenticated" => true
"allow_image_prioritization" => true
"browser_locale" => "en-US"
"deep_link_action" => null
"triggerable_experiments" => array:201 [▶]
"visible_url" => "/login/"
"is_tablet_agent" => false
"utm_campaign" => null
"browser_type" => 4
"deep_link" => ""
"site_type" => 0
"from_open_in_app_click" => null
"invite_code" => null
"use_react" => true
"locale" => "en-US"
"utm_medium" => null
"giftwrap_holdout" => false
"app_version" => "d6936eb"
"site_const" => array:5 [▶]
"real_ip" => "39.48.31.185"
"user_agent_is_ios_9_2_or_above" => false
"active_experiments" => array:2 [▼
"related_pins_closeup" => "enabled"
"render_using_react_3" => "enabled"
]
"user" => array:39 [▼
"is_employee" => false
"username" => "USERNAME HERE"
"last_name" => ""
"domain_verified" => false
"nags" => []
"image_medium_url" => "https://s-media-cache-ak0.pinimg.com/avatars/bookler4288_1461317847_75.jpg"
"has_password" => true
"full_name" => "FULL NAME HERE"
"image_small_url" => "https://s-media-cache-ak0.pinimg.com/avatars/bookler4288_1461317847_30.jpg"
"gplus_url" => null
"id" => "202310345669271373"
"is_write_banned" => false
"first_name" => "FULL NAME HERE"
"domain_url" => "URL HERE"
"has_seen_notifications" => false
"personalize_from_offsite_browsing" => true
"facebook_timeline_enabled" => false
"personalize_nux_from_offsite_browsing" => false
"connected_to_rakuten" => false
"facebook_id" => ""
"connected_to_google" => false
"is_partner" => false
"type" => "user"
"email" => "EMAIL HERE"
"image_large_url" => "https://s-media-cache-ak0.pinimg.com/avatars/bookler4288_1461317847_140.jpg"
"connected_to_yahoo" => false
"verified_identity" => []
"twitter_url" => null
"facebook_url" => null
"twitter_publish_enabled" => false
"ads_customize_from_conversion" => true
"facebook_publish_stream_enabled" => false
"connected_to_microsoft" => false
"gender" => "female"
"created_at" => "Fri, 22 Apr 2016 09:35:40 +0000"
"login_state" => 1
"website_url" => "WEBSITE LINK HERE"
"country" => "PK"
"extension_access_token" => null
]
"deep_link_default" => ""
"http_referrer" => "https://nl.pinterest.com/"
"is_mobile_agent" => false
"is_internal_ip" => false
"language" => "en"
"is_sterling_on_steroids" => false
"referrer" => null
"user_agent_can_use_native_app" => false
"browser_name" => "Firefox"
"country" => "PK"
"error_template_path" => "templates/error.nunjucks"
]
"resource_response" => array:2 [▼
"data" => array:1 [▼
"token_type" => "bearer"
]
"error" => null
]
]

from php-pinterest-bot.

seregazhuk avatar seregazhuk commented on July 25, 2024

Yes, logged in successfully, let's debug. Next on line 115 place var_dump($this->request->isLoggedIn());
And in ProviderLoginCheckWrapper on line 53 var_dump($methodRequiresLogin && !$isLoggedIn);

from php-pinterest-bot.

capripio avatar capripio commented on July 25, 2024

Line 115:

Request {#172
#userAgent: "Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Firefox/31.0"
#http: CurlAdapter {#178
-curl: Unknown resource @243
}
#loggedIn: null
#cookieJar: "pinterest_cookie"
#options: array:11 [▼
10018 => "Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Firefox/31.0"
19913 => 1
64 => 0
52 => 1
10102 => "gzip,deflate"
10023 => array:11 [▼
0 => "Accept: application/json, text/javascript, /; q=0.01"
1 => "Accept-Language: en-US,en;q=0.5"
2 => "DNT: 1"
3 => "Host: nl.pinterest.com"
4 => "Content-Type: application/x-www-form-urlencoded; charset=UTF-8"
5 => "X-Pinterest-AppState: active"
6 => "X-NEW-APP: 1"
7 => "X-APP-VERSION: 04cf8cc"
8 => "X-Requested-With: XMLHttpRequest"
9 => "X-CSRFToken: 1234"
10 => "Cookie: csrftoken=1234;"
]
10016 => "https://nl.pinterest.com/"
10031 => "pinterest_cookie"
10082 => "pinterest_cookie"
47 => 1
10015 => "source_url=%2Flogin%2F&data=%7B%22options%22%3A%7B%22username_or_email%22%3A%22social%40bookler.xyz%22%2C%22password%22%3A%22windows%22%7D%2C%22context%22%3A%7B%7D%7D"
]
+csrfToken: null
#requestHeaders: array:9 [▼
0 => "Accept: application/json, text/javascript, /; q=0.01"
1 => "Accept-Language: en-US,en;q=0.5"
2 => "DNT: 1"
3 => "Host: nl.pinterest.com"
4 => "Content-Type: application/x-www-form-urlencoded; charset=UTF-8"
5 => "X-Pinterest-AppState: active"
6 => "X-NEW-APP: 1"
7 => "X-APP-VERSION: 04cf8cc"
8 => "X-Requested-With: XMLHttpRequest"
]
}

from php-pinterest-bot.

capripio avatar capripio commented on July 25, 2024

53 returns false, which cause exception of auth

from php-pinterest-bot.

seregazhuk avatar seregazhuk commented on July 25, 2024

I see, i think it is because of rights. When logged in request is made, it saves cookies on disk to parse and to get token from it. In Request.php on 185 line. I think script has no rights to create files, so no token has been parsed.
It's my fault, I should raise an exception here. Please check rights on your directory.

from php-pinterest-bot.

seregazhuk avatar seregazhuk commented on July 25, 2024

Script saves cookies in it's root path in pinterest_cookie file.

from php-pinterest-bot.

capripio avatar capripio commented on July 25, 2024

are you talking about following function? Its doesn't seems to called, i can't debug it here. and I am using Windows I don't think any issue with permission?

public static function createQuery(array $data = [], $sourceUrl = '/', $bookmarks = [])
{
    $request = self::createRequestData($data, $sourceUrl, $bookmarks);

    return UrlHelper::buildRequestString($request);
}

from php-pinterest-bot.

seregazhuk avatar seregazhuk commented on July 25, 2024

No, Api\Request.php line 185:

public function setLoggedIn()
    {
        $this->csrfToken = CsrfHelper::getTokenFromFile($this->cookieJar);   // <--- parsing token from file
        if (!empty($this->csrfToken)) {
            $this->loggedIn = true;
        }

        return $this;
    }

I think the problem is here. No token has been parsed.

from php-pinterest-bot.

capripio avatar capripio commented on July 25, 2024

well this code intersect with in line no. 158.

from php-pinterest-bot.

capripio avatar capripio commented on July 25, 2024
public function setLoggedIn()
{
    $this->csrfToken = CsrfHelper::getTokenFromFile($this->cookieJar);
    if (!empty($this->csrfToken)) {
        $this->loggedIn = true;
    }

    return $this;
}

from php-pinterest-bot.

seregazhuk avatar seregazhuk commented on July 25, 2024

Yes, here. I think $this->csrfToken is empty in your case.

from php-pinterest-bot.

capripio avatar capripio commented on July 25, 2024

yes it does.

from php-pinterest-bot.

seregazhuk avatar seregazhuk commented on July 25, 2024

try to change directory permissions

from php-pinterest-bot.

capripio avatar capripio commented on July 25, 2024

can you tell me when your code store file I might debug it out!

from php-pinterest-bot.

seregazhuk avatar seregazhuk commented on July 25, 2024

If you are using Laravel, it will be in public folder
534f908855

from php-pinterest-bot.

capripio avatar capripio commented on July 25, 2024

hmm that's strange I've provided right too all users still unable to do login.

from php-pinterest-bot.

capripio avatar capripio commented on July 25, 2024

however thanks for help, since its seems issue on my side, I must have miss something. I will close this bug and debug whole thing in morning.
Have a good day!
Good Night.

from php-pinterest-bot.

seregazhuk avatar seregazhuk commented on July 25, 2024

Ok, good luck to you! May be try manually create this file empty in laravels public folder.

from php-pinterest-bot.

capripio avatar capripio commented on July 25, 2024

ok let me try it now!

from php-pinterest-bot.

capripio avatar capripio commented on July 25, 2024

it's worked! I guess I need to learn about 2 new functions 👍

from php-pinterest-bot.

seregazhuk avatar seregazhuk commented on July 25, 2024

Oh, that's great!)

from php-pinterest-bot.

capripio avatar capripio commented on July 25, 2024

Thanks! finally I can sleep now :D you know what I mean! Good Night and Thanks again!

from php-pinterest-bot.

seregazhuk avatar seregazhuk commented on July 25, 2024

Good night) I've published a new release of library with this fix. Update tomorrow, and there will be no need to change library source.

from php-pinterest-bot.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.