特斯拉API(非官方) - 通过卷曲进行测试



在编写针对特斯拉API的任何实际代码之前,我想我会破解一些卷发命令以熟悉。已经挣扎了。只是想通过以下方式将OAuth代币返回:

curl -X POST  -H 'Content-Type: application/json' -d '{"grant_type": "password", "client_id": "81527cff06843c838fe1e431c2ef2106796384", "client_secret": "c7257eb71a564034f9419ee651c7d0e5f7aa6bfbd18bafb5c5c033b093bb2fa3", "email": "myemail@email.com","password": "mypassword"}' 'https://owner-api.teslamotors.com/oauth/token'

产生以下错误:

{"error":"invalid_client","error_description":"Client authentication failed due to unknown client, no client authentication included, or unsupported authentication method."}

我怀疑client_id and client_secret在https://tesla-api.timdorr.com/api-basics/authentication已被撤销,但是当我尝试注册一个SmartCar帐户时也不对我有用。

好吧,此命令按原样运行良好,我在复制/粘贴它时只是拧紧client_id。在此处留下更正的版本,以防其他任何人都想卷曲Tesla API。

curl -X POST  -H 'Content-Type: application/json' -d '{"grant_type": "password", "client_id": "81527cff06843c8634fdc09e8ac0abefb46ac849f38fe1e431c2ef2106796384", "client_secret": "c7257eb71a564034f9419ee651c7d0e5f7aa6bfbd18bafb5c5c033b093bb2fa3", "email": "myemail@email.com","password": "mypassword"}' 'https://owner-api.teslamotors.com/oauth/token'

然后使用接收令牌进行查询:

curl --request GET --header 'Authorization: Bearer 32819532809859320539205djfdsjfkdsd' 'https://owner-api.teslamotors.com/api/1/vehicles'

,然后:

curl --request GET --header 'Authorization: Bearer 32819532809859320539205djfdsjfkdsd' 'https://owner-api.teslamotors.com/api/1/vehicles/?id=0123456789'

我编写了这些简单的python脚本,以访问带有最新要求的特斯拉API,可用于使任何人开始使用API。

https://github.com/marky0/tesla_api_lite

最新更新