teslamotors / vehicle-command

Apache License 2.0
387 stars 85 forks source link

Partner token generation for China region fails #100

Closed rawmean closed 3 weeks ago

rawmean commented 7 months ago

Documentation was updated to include the China region endpoint. However, when I try to generate a partner token (so that I can register), it fails (see below)

AUDIENCE_CN="https://fleet-api.prd.cn.vn.cloud.tesla.cn"

# Partner authentication token request
curl --request POST \
  --header 'Content-Type: application/x-www-form-urlencoded' \
  --data-urlencode 'grant_type=client_credentials' \
  --data-urlencode "client_id=$CLIENT_ID" \
  --data-urlencode "client_secret=$CLIENT_SECRET" \
  --data-urlencode 'scope=openid vehicle_device_data vehicle_cmds vehicle_charging_cmds' \
  --data-urlencode "audience=$AUDIENCE_CN" \
  'https://auth.tesla.cn/oauth2/v3/token'

Response:

HTTP/2 400 
{"error":"unauthorized_client","error_description":"We don't recognize this client_id and client_secret combination","error_uri":"https://auth.tesla.cn/error/reference/a4a4919e-81b7-4c44-8c55-f4d8d682ddf2-1702318465851"}

client_id and client_secret used in the request are valid and work for NA and EU regions.

Note that the request is being sent to https://auth.tesla.cn/oauth2/v3/token. Sending the request to https://auth.tesla.com/oauth2/v3/token results in the following error:

HTTP/2 400 
  {"error":"invalid_request","error_description":"Invalid resource","error_uri":"https://auth.tesla.com/error/reference/396f8939-be75-4716-80a1-10b77a1c2f25-1702318621906"}
itsMeDavidV commented 7 months ago

ehh @sethterashima does this mean we need a separate .cn developer account and/or permissions?

rawmean commented 7 months ago

ehh @sethterashima does this mean we need a separate .cn developer account and/or permissions?

I certainly hope not. How do we even create separate one for China? Currently, there is no way to indicate that the region for developer account.

@itsMeDavidV Can you also reproduce this problem?

itsMeDavidV commented 7 months ago

@rawmean yes, unfortunately just reproduced this using a Tesla China account :/

Note:

Screenshot 2023-12-11 at 11 58 09 AM

itsMeDavidV commented 6 months ago

@rawmean Have you found an answer to this issue?

Looking at localized China docs, it does say to:

Set up a third-party account at https://developer.tesla.cn/

@sethterashima does this mean that we'll need to setup a separate developer account for use of the China region?

This is the response I get from https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/partner_accounts.

["error_description": , "response": <null>, "error": client not found]

na and eu registration works fine.

rawmean commented 6 months ago

@rawmean Have you found an answer to this issue?

Looking at localized China docs, it does say to:

Set up a third-party account at https://developer.tesla.cn/

@sethterashima does this mean that we'll need to setup a separate developer account for use of the China region?

This is the response I get from https://fleet-api.prd.cn.vn.cloud.tesla.cn/api/1/partner_accounts.

["error_description": , "response": <null>, "error": client not found]

na and eu registration works fine.

No, getting a parter token still fails for CN. I don't see how we can create a developer account for China.

itsMeDavidV commented 6 months ago

I don't see how we can create a developer account for China.

My hunch is that China developer accounts, like China user accounts, are segregated from the rest of the Global accounts and we could quite literally make an identical dev account for the .cn domain, would be nice if someone from Tesla could confirm/clarify this.

rawmean commented 6 months ago

I don't see how we can create a developer account for China.

My hunch is that China developer accounts, like China user accounts, are segregated from the rest of the Global accounts and we could quite literally make an identical dev account for the .cn domain, would be nice if someone from Tesla could confirm/clarify this.

That's a reasonable assumption, but how would one create a dev account associated with .cn? The Tesla developer site does not provide an option for creating a deva account dedicated to China. Also, why would they require such a thing? It only adds to the complexity (maintaining separate dev accounts for the same app).

I have also reported to the fleet support email a while ago, but no response.

itsMeDavidV commented 6 months ago

@sethterashima Any update on this? This is a huge issue that has affected many users for weeks now.

bassmaster187 commented 5 months ago

I have the same problem. Any news or workarounds?

itsMeDavidV commented 5 months ago

@ThomasAlxDmy @derekargueta @sethterashima any update on this? Should we setup separate developer accounts at https://developer.tesla.cn/ or is there something else we need to do to have our Client ID/Secrets recognized in China?

jonahwh commented 5 months ago

Requesting an update on this too - an additional note is that if you try to create an account on https://auth.tesla.cn/, you are prompted to verify a phone number, and are only given the option to choose the +86 (China) country code, but it seems as if it's effectively impossible (without doing something quasi-legal) for a non-Chinese national to get a +86 phone number

image

itsMeDavidV commented 5 months ago

@sethterashima @derekargueta @ThomasAlxDmy can we get any answer on this??? This issue was created almost 3 months ago.

itsMeDavidV commented 5 months ago

Update: Tesla got back to me and clarified that the Tesla instances for NA/EU are separated from CN so we will have to create a separate dev account and app at https://developer.tesla.cn/ to support CN users

They will be updating docs on this and I will be testing this out to confirm later today.

jonahwh commented 4 months ago

Any updates here? I noticed the docs now say

To make calls to vehicles in China, you must create an account on https://www.tesla.cn/ and create a separate application on https://developer.tesla.cn/. This requires a +86 phone number.

Does this mean if someone doesn't have a physical presence in mainland China, they will be unable to support users in China?

If that's the case, I'm not happy about it, but I understand, but I'd appreciate some official word that the +86 phone number requirement won't be changing.

jaggerc commented 4 months ago

If I'm not mistaken the law in China requires all data to be stored in China so this seems to be the appropriate way for Tesla to handle this.

jonahwh commented 4 months ago

I understand that, but I'm specifically wondering about the +86 phone number requirement.

jaggerc commented 4 months ago

Get a cheap voip number if you want to circumvent, pretty sure Tesla isn't responding to this due to the legal issues.

jonahwh commented 4 months ago

I spent a couple hours the other day doing research trying to do just that. There's no legitimate service out there that offers Chinese phone numbers that can get text messages, that I could find. If you know of one please share :)

The only thing I could find is people offering to do it gray-market ways via Telegram or WhatsApp which is not the path I'd want to take. Additionally if it's a shared phone number, or one that someone else can access, I'm concerned that would give them access to my Chinese Tesla Developer account, via account recovery, as don't have proof of this, but I don't know how the Chinese Tesla accounts work, but it's my understanding that mobile numbers in China are highly coupled to an individual, so I wouldn't be surprised if it was the case.