首页 > 解决方案 > 无法使用 Python 请求模块登录 PSN

问题描述

我正在尝试使用从浏览器的检查元素获取的 python 请求模块和 API登录 PSN https://www.playstation.com/en-in/sign-in-and-connect/ 。下面是代码

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)

有了这个,我得到了来自服务器的以下响应。

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

我可以知道其他登录 PSN 网络的方法吗?最好使用 API 模型而不是硒?我的目标是使用我的凭据登录 PSN 网络并更改密码,但似乎只卡在登录页面...

标签: authenticationpython-requestsselenium-chromedriverbrowser-automationlogin-automation

解决方案


推荐阅读