在针对Tesla API编写任何实际代码之前,我想我应该使用一些cURL命令来熟悉它。已经在挣扎了。只是尝试通过以下方式取回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和client_secret在https://tesla-api.timdorr.com/api-basics/authentication共享的账户被撤销了,但当我尝试注册一个智能汽车账户时,给了我一个不同的账户,这对我来说也不起作用。
发布于 2019-05-18 03:44:40
这个命令工作得很好,我只是在复制/粘贴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'然后使用收到的令牌进行get查询:
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'https://stackoverflow.com/questions/56188898
复制相似问题