-
Notifications
You must be signed in to change notification settings - Fork 765
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unauthorized using Tesla Fleet API directly #4081
Comments
Since I did not fully understood what should I change to my own domain I also tried: TESLA_API_HOST=https://myproxy.mydomain.com I also have one access_token that I am using to test Tesla Http Proxy. |
The env variables needed to set are displayed in the box... named # API Fleet see also: #3959 |
But it is not stated witch ones and to what. Breaking down what I choose: TESLA_API_HOST I assume this is the one that I need to change for my own domain but also there is a line saying: |
https://docs.teslamate.org/docs/configuration/environment_variables |
Just click the link, highlighted in green Or just read https://docs.teslamate.org/docs/guides/api#tesla-fleet-api where it is directly explained |
@JakobLichterfeld then my config is right and it is what should be used. The issue mantains and my doubts about which urls should I put in each env variable are gone. @adampetrovic thats what I was thinking teslamate wanted, us to setup the proxy like home assistant integration. Thats why I tried both urls int config. I actually have a proxy working with a lets encrypt certificate but only opened to my local network although I would prefer a self signed one for this matter too. #3979 is about the self signed certificate issue. |
If your config is right, where is your issue?
You should really reread the docs. TeslaMate does not use the FleetAPI in any kind, as it has many drawbacks. There is a way to use the Fleet API endpoints and still use TeslaMate, that's what the doc from @jlestel is talking about. |
btw. your Postgres should be updated --> https://docs.teslamate.org/docs/maintenance/upgrading_postgres |
So after I setup env variables like the docs say I get 401 error while accessing car data. All this config discussion was because even reading the docs I was not sure how to proceed, like @adampetrovic agreed it was not very clear. Thats why I said that I tried to test, before creating the issue, the 2 configs that I took away by reading the documentation. |
The documentation does not explain how to obtain tokens with the Fleet API, but to be authenticated by the Fleet API, you need to obtain tokens as with the legacy API. The endpoint to obtain the initial tokens: https://developer.tesla.com/docs/fleet-api#third-party-token Indeed, if your tokens are not valid, the return code is 401. |
I tried to use tokens generated via Tesla HTTP Proxy HomeAssistant Addon, they generate the tokens. It failed on teslamate UI |
I am facing the very same issue, if I configure TeslaMate to use the Fleet API, I get a 401 when calling to
I have tested the tokens via simple cURL calls and they are working as expected, so it looks like something is off. Configuring TeslaMate via Owner API works well. |
It happens the same with me when I try to put the tokens that work with Home Assistant integration and via curl. If I log out and try to use the codes it doesnt work.When I change from owner’s api to Tesla Fleet API I get 200 from auth.tesla and 401 from fleet api.
|
That's right, the tokens I get from the explained procedure work well when using the Home Assistant integration in Fleet API mode. |
Were you able to address the issue and successfully switch over to fleet API? What did you do to fix the 401 issue? |
No, I wasn't. I was just reporting that my tokens work well when calling Fleet API in other scenarios, such as simple cURL calls or Home Assistant unofficial integration. |
Fixed by this PR. Can you try the fix with this image ? |
To do so, please follow: https://docs.teslamate.org/docs/development#testing-with-our-ci-which-builds-the-docker-images-automatically-per-pr |
with the pr image, I'm still having the 401 error.
But when I call the endpoint via curl, I can see a successful response.
|
@XxTopKillerzZ did you check the necessary boxes when you registered the Tesla application and when you registered your Tesla account on your own Tesla application?
@yangiak Unlike initial issue, I see it's a call with a vehicle ID. so you managed to list the vehicles previously? (/products) Does the problem occur after refreshing the tokens only? I cannot reproduce your case by starting a teslamate with valid credentials. |
Does not work for me. Stuck with |
Hello @jlestel , The product call also had error 401
But I can call the endpoint myself.
|
Which we tried to provide with the docs https://docs.teslamate.org/docs/guides/api ("Requirements: Advanced IT skills") Every PR to improve the docs is welcome. For most users Fleet API has only drawbacks atm, therefore it is nor recommended, nor fully supported, nor our focus point. |
But since the owners api is deprecated and likely to go offline, either Teslamate adapts or stops working. I also have IT skills and have configured the fleet api proxy within homeassistant to work with the forked component and it works. But I haven’t spent enough time with Teslamate to figure out why my access and refresh tokens are not working. PS: I’m not imposing and if it doesn’t work then that’s the way it is |
Fleet API is gargabe for most users now but we have to deal with it. Im already using Fleet API for home assistant because I had too. This means I agreed to an EULA that forbids me from using old APIs. Until I manage to make teslamate work im violating it. Im also having the same problem, error 401, but everything works using curl and homeassistant. |
This issue will be closed if no feedback on the above test build is received in the next 3 days. |
I am currently traveling, but I think I can give a try later tonight. |
I did try that image and nothing changed. To be honest, I don't even know how the change could possibly fix the issue since |
It does not work for me. I assume I’m supposed to change the build, pull new image, log out from teslamate and login with the same tokens I use in homeassistant right? |
The fix I did worked fine in dev... but I confirm that with the PR image, it's still Sorry for the back and forth, usually I have the same behavior in dev and when it's release: I'm trying to find the right syntax. |
Now it works, i'm able to sign in using Fleet API tokens. I have another issue now which is related with the https connection as per described in this issue: #3979 |
Perfect, thanks for your feedback! Will be included in next release. |
Awesome, thanks for the feedback. Fix will be included in upcoming release. |
I was finally able to test it today, I can confirm the |
Perfect, thanks for the feedback, and thanks for your patient till next release which will have it included. |
It is working for me too, had to log out and log in with access/refresh tokens generated using tesla-http-proxy. |
Can this be called out in the docs? I just went through the rabbit hole of setting all of this up with MyTeslaMate because the docs made it sound like the most future-proof way of doing things, only to have it not reliably detect the car's state... I'll switch back to the older API for now, but the "preferred" and "fully supported" way of doing things should be made obvious. |
It is not mentioned in any official installation guide. In the fleet API guide it is called multiple times, even the drawbacks. |
Thank you. Since you were the first to stumble, you won't be the last. So I am always open to improvements and I understand your point. |
You forgot to highlight the sentence Anyways, clarification in #4173 |
Is there an existing issue for this?
What happened?
I am trying to make the change to Tesla Fleet API like the docs say. Everything used to work with the old API.
I already have a developer Tesla account with client id and secret. Hosted public key. Proxy working for HomeAssistant Tesla Integration and everything works fine.
My interpretation of the docs at https://docs.teslamate.org/docs/guides/api#tesla-fleet-api is that I only need to change TESLA_AUTH_CLIENT_ID which I did.
It says to "Add the following environment variable with your own domain" but then does not say which one.
I used the following configuration:
When I initialize I get the logs that i'm putting here.
Expected Behavior
Steps To Reproduce
Relevant log output
Screenshots
No response
Additional data
No response
Type of installation
Docker
Version
v.130.0
The text was updated successfully, but these errors were encountered: