question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Exception: Wrong credentials

See original GitHub issue

Hi, thanks for maintaining this module!

I can’t seem to create a pin without getting a wrong credential error. I’ve cross referenced my credentials several time so I am positive they are correct. I have copy and pasted them straight from Pinterest to make sure.

from py3pin.Pinterest import Pinterest

pinterest = Pinterest(email=email,
                      password=password,
                      username=username,
                      cred_root=cred_root)

# get boards (works fine)
board_batch = pinterest.boards() 

# example board ID
pinterest.pin(board_id='845258473083496787', image_url='https://www.321howto.com/wp-content/uploads/2017/11/Perfect-Garden-2018.jpg', description='A truly perfect description!', title='Great title', link='www.google.com')

Error code:

---------------------------------------------------------------------------
HTTPError                                 Traceback (most recent call last)
~/anaconda3/lib/python3.6/site-packages/py3pin/Pinterest.py in login(self)
    116         try:
--> 117             response = self.post(url=CREATE_USER_SESSION, data=data)
    118             response = response.json()

~/anaconda3/lib/python3.6/site-packages/py3pin/Pinterest.py in post(self, url, data, files)
    103     def post(self, url, data=None, files=None):
--> 104         return self.request('POST', url=url, data=data, files=files)
    105 

~/anaconda3/lib/python3.6/site-packages/py3pin/Pinterest.py in request(self, method, url, data, files)
     95 
---> 96         response.raise_for_status()
     97         self.registry.update(Registry.Key.COOKIES, response.cookies)

~/anaconda3/lib/python3.6/site-packages/requests/models.py in raise_for_status(self)
    939         if http_error_msg:
--> 940             raise HTTPError(http_error_msg, response=self)
    941 

HTTPError: 429 Client Error: Too Many Requests for url: https://www.pinterest.com/resource/UserSessionResource/create/

During handling of the above exception, another exception occurred:

Exception                                 Traceback (most recent call last)
~/anaconda3/lib/python3.6/site-packages/py3pin/Pinterest.py in login(self)
    116         try:
--> 117             response = self.post(url=CREATE_USER_SESSION, data=data)
    118             response = response.json()

~/anaconda3/lib/python3.6/site-packages/py3pin/Pinterest.py in post(self, url, data, files)
    103     def post(self, url, data=None, files=None):
--> 104         return self.request('POST', url=url, data=data, files=files)
    105 

~/anaconda3/lib/python3.6/site-packages/py3pin/Pinterest.py in request(self, method, url, data, files)
     92         if response.status_code == 401:
---> 93             self.login()
     94             response = self.http.request(method, url, data=data, headers=headers, files=files, proxies=self.proxies)

~/anaconda3/lib/python3.6/site-packages/py3pin/Pinterest.py in login(self)
    120             self.login_failed = True
--> 121             raise Exception("Wrong credentials")
    122         return response

Exception: Wrong credentials

During handling of the above exception, another exception occurred:

Exception                                 Traceback (most recent call last)
~/anaconda3/lib/python3.6/site-packages/py3pin/Pinterest.py in login(self)
    116         try:
--> 117             response = self.post(url=CREATE_USER_SESSION, data=data)
    118             response = response.json()

~/anaconda3/lib/python3.6/site-packages/py3pin/Pinterest.py in post(self, url, data, files)
    103     def post(self, url, data=None, files=None):
--> 104         return self.request('POST', url=url, data=data, files=files)
    105 

~/anaconda3/lib/python3.6/site-packages/py3pin/Pinterest.py in request(self, method, url, data, files)
     92         if response.status_code == 401:
---> 93             self.login()
     94             response = self.http.request(method, url, data=data, headers=headers, files=files, proxies=self.proxies)

~/anaconda3/lib/python3.6/site-packages/py3pin/Pinterest.py in login(self)
    120             self.login_failed = True
--> 121             raise Exception("Wrong credentials")
    122         return response

Exception: Wrong credentials

During handling of the above exception, another exception occurred:

Exception                                 Traceback (most recent call last)
<ipython-input-2-b792fad0d3c1> in <module>
      8 
      9 # make pin
---> 10 pinterest.pin(board_id='845258473083496787', image_url='https://www.321howto.com/wp-content/uploads/2017/11/Perfect-Garden-2018.jpg', description='A truly perfect description!', title='Great title', link='www.google.com')

~/anaconda3/lib/python3.6/site-packages/py3pin/Pinterest.py in pin(self, board_id, image_url, description, link, title)
    319         data = self.req_builder.buildPost(options=options, source_url=source_url)
    320 
--> 321         return self.post(url=PIN_RESOURCE_CREATE, data=data).json()
    322 
    323     def repin(self, board_id, pin_id):

~/anaconda3/lib/python3.6/site-packages/py3pin/Pinterest.py in post(self, url, data, files)
    102 
    103     def post(self, url, data=None, files=None):
--> 104         return self.request('POST', url=url, data=data, files=files)
    105 
    106     def login(self):

~/anaconda3/lib/python3.6/site-packages/py3pin/Pinterest.py in request(self, method, url, data, files)
     91         response = self.http.request(method, url, data=data, headers=headers, files=files, proxies=self.proxies)
     92         if response.status_code == 401:
---> 93             self.login()
     94             response = self.http.request(method, url, data=data, headers=headers, files=files, proxies=self.proxies)
     95 

~/anaconda3/lib/python3.6/site-packages/py3pin/Pinterest.py in login(self)
    119         except Exception as e:
    120             self.login_failed = True
--> 121             raise Exception("Wrong credentials")
    122         return response
    123 

Exception: Wrong credentials

Looks like there’s a 429 error in the mix which is odd as this is my only attempted request…

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
bstoilovcommented, Sep 17, 2019

Good to hear that you resolved the issue. I will update the readme with this so other people don’t strugle

0reactions
Lachlan00commented, Sep 17, 2019

Hi again bstoilov,

I looked into it a bit more and it turned out the reason I couldn’t log in with py3-pinterest was that it was using the linked google account to log in. I removed the google account link and now the module works fine.

Sorry to bother you and thanks again!

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to throw any Exceptions for wrong credentials when ...
I am trying to set up authorization server and resource server in the same app. In grant_type=client_credentials , for correct client_id and ...
Read more >
Spring Security - Distinguishing login failure exceptions
When we fail to log in, we may write the wrong username or the wrong password, but for security reasons, the server usually...
Read more >
InvalidCredentialException Class (System.Security ...
This exception indicates that the underlying stream isn't in a valid state and that you can't retry the authentication using the NegotiateStream instance....
Read more >
AuthenticationException (Java Platform SE 7 )
This exception is thrown when an authentication error occurs while accessing the naming or directory service. An authentication error can happen, ...
Read more >
BadCredentialsException (Spring Security 4.2.4.RELEASE API)
Thrown if an authentication request is rejected because the credentials are invalid. For this exception to be thrown, it means the account is...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found