Unable to login into PSN using Python requests module

1.1k Views Asked by At

I am trying to login into PSN https://www.playstation.com/en-in/sign-in-and-connect/ using python requests module and API got from the inspect element of browser. Below is the code

import requests
login_data = {
    'password': "mypasswordhere",
    'username': "myemailhere",
}

header = {
    'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.129 Safari/537.36'
}

with requests.Session() as s1:
    url = "https://auth.api.sonyentertainmentnetwork.com/2.0/oauth/token"
    r = s1.post(url, data = login_data, headers = header)
    print(r.text)

With this, I got below response from the server.

{"error":"invalid_client","error_description":"Bad client credentials","error_code":4102,"docs":"https://auth.api.sonyentertainmentnetwork.com/docs/","parameters":[]}

Can I know any alternative method to login into PSN network? Preferably using API model instead of selenium? My objective is to login into PSN network with my credentials and change password but seems got stuck in login page only...

0

There are 0 best solutions below