diff --git a/plugins/tesla/.claude-plugin/plugin.json b/plugins/tesla/.claude-plugin/plugin.json index e398492a..58569131 100644 --- a/plugins/tesla/.claude-plugin/plugin.json +++ b/plugins/tesla/.claude-plugin/plugin.json @@ -1,7 +1,7 @@ { "name": "tesla", "displayName": "Tesla Fleet Management API", - "version": "0.4.1", + "version": "0.4.2", "description": "Integrate and consume the APIMatic-generated Tesla Fleet Management API SDK — bundled skills for C#/.NET, Python, TypeScript.", "author": { "name": "APIMatic", diff --git a/plugins/tesla/.codex-plugin/plugin.json b/plugins/tesla/.codex-plugin/plugin.json index 1c561183..688b05af 100644 --- a/plugins/tesla/.codex-plugin/plugin.json +++ b/plugins/tesla/.codex-plugin/plugin.json @@ -1,6 +1,6 @@ { "name": "tesla", - "version": "0.4.1", + "version": "0.4.2", "description": "Integrate and consume the APIMatic-generated Tesla Fleet Management API SDK — bundled skills for C#/.NET, Python, TypeScript.", "skills": "./skills", "interface": { diff --git a/plugins/tesla/.cursor-plugin/plugin.json b/plugins/tesla/.cursor-plugin/plugin.json index a149252d..5319893f 100644 --- a/plugins/tesla/.cursor-plugin/plugin.json +++ b/plugins/tesla/.cursor-plugin/plugin.json @@ -1,7 +1,7 @@ { "name": "tesla", "displayName": "Tesla Fleet Management API", - "version": "0.4.1", + "version": "0.4.2", "description": "Integrate and consume the APIMatic-generated Tesla Fleet Management API SDK — bundled skills for C#/.NET, Python, TypeScript.", "author": { "name": "APIMatic", diff --git a/plugins/tesla/plugin.json b/plugins/tesla/plugin.json index a149252d..5319893f 100644 --- a/plugins/tesla/plugin.json +++ b/plugins/tesla/plugin.json @@ -1,7 +1,7 @@ { "name": "tesla", "displayName": "Tesla Fleet Management API", - "version": "0.4.1", + "version": "0.4.2", "description": "Integrate and consume the APIMatic-generated Tesla Fleet Management API SDK — bundled skills for C#/.NET, Python, TypeScript.", "author": { "name": "APIMatic", diff --git a/plugins/tesla/skills/dotnet/dotnet-authentication/SKILL.md b/plugins/tesla/skills/dotnet/dotnet-authentication/SKILL.md index 8dc4d4f0..d0fa7eb1 100644 --- a/plugins/tesla/skills/dotnet/dotnet-authentication/SKILL.md +++ b/plugins/tesla/skills/dotnet/dotnet-authentication/SKILL.md @@ -35,6 +35,7 @@ options.ThirdpartytokenAuthorizationCode = new OAuth2AuthorizationCodeCredential ClientId = "...", ClientSecret = "...", RedirectUri = "https://app.example.com/callback", + Audience = "https://fleet-api.prd.na.vn.cloud.tesla.com", // required — sent on the code exchange Scope = "...", // optional State = "...", // optional CSRF token Pkce = PkceMethod.S256, // default; RFC 7636 @@ -62,11 +63,12 @@ options.ThirdpartytokenClientCredentials = new OAuth2ClientCredentials { ClientId = "...", ClientSecret = "...", + Audience = "https://fleet-api.prd.na.vn.cloud.tesla.com", // required — the Fleet API base URL of the token's region Scope = "..." // optional }; ``` -The SDK fetches the token from `https://fleet-auth.prd.vn.cloud.tesla.com/oauth2/v3/token` and caches it, acquiring a fresh one when it expires; on a `401` it drops the cached token, acquires a new one and re-sends the call once (the upload exception is under **Token caching & refresh**). The token request carries the client id and secret in the form body. +The SDK fetches the token from `https://fleet-auth.prd.vn.cloud.tesla.com/oauth2/v3/token` and caches it, acquiring a fresh one when it expires; on a `401` it drops the cached token, acquires a new one and re-sends the call once (the upload exception is under **Token caching & refresh**). The token request carries the client id, secret and `audience` in the form body. ## Credential providers @@ -110,7 +112,7 @@ A credentials property left `null` is read from an environment variable when the | Property on `TeslaFleetManagementApiClientOptions` | Environment variables | | --- | --- | | `BearerAuth` | `TESLA_FLEET_MANAGEMENT_API_BEARER_AUTH` | -| `ThirdpartytokenClientCredentials` | `TESLA_FLEET_MANAGEMENT_API_THIRDPARTYTOKEN_CLIENT_CREDENTIALS_CLIENT_ID`, `TESLA_FLEET_MANAGEMENT_API_THIRDPARTYTOKEN_CLIENT_CREDENTIALS_CLIENT_SECRET`, `TESLA_FLEET_MANAGEMENT_API_THIRDPARTYTOKEN_CLIENT_CREDENTIALS_SCOPE` (optional) | +| `ThirdpartytokenClientCredentials` | `TESLA_FLEET_MANAGEMENT_API_THIRDPARTYTOKEN_CLIENT_CREDENTIALS_CLIENT_ID`, `TESLA_FLEET_MANAGEMENT_API_THIRDPARTYTOKEN_CLIENT_CREDENTIALS_CLIENT_SECRET`, `TESLA_FLEET_MANAGEMENT_API_THIRDPARTYTOKEN_CLIENT_CREDENTIALS_AUDIENCE`, `TESLA_FLEET_MANAGEMENT_API_THIRDPARTYTOKEN_CLIENT_CREDENTIALS_SCOPE` (optional) | `options.ThirdpartytokenAuthorizationCode` has no environment default. @@ -162,8 +164,10 @@ Check every value **the scheme you chose** needs. The rows below are not one che | `ClientId` | `ThirdpartytokenAuthorizationCode` | — | | `ClientSecret` | `ThirdpartytokenAuthorizationCode` | — | | `RedirectUri` | `ThirdpartytokenAuthorizationCode` | — | +| `Audience` | `ThirdpartytokenAuthorizationCode` | — | | `ClientId` | `ThirdpartytokenClientCredentials` | `TESLA_FLEET_MANAGEMENT_API_THIRDPARTYTOKEN_CLIENT_CREDENTIALS_CLIENT_ID` | | `ClientSecret` | `ThirdpartytokenClientCredentials` | `TESLA_FLEET_MANAGEMENT_API_THIRDPARTYTOKEN_CLIENT_CREDENTIALS_CLIENT_SECRET` | +| `Audience` | `ThirdpartytokenClientCredentials` | `TESLA_FLEET_MANAGEMENT_API_THIRDPARTYTOKEN_CLIENT_CREDENTIALS_AUDIENCE` | ## Notes diff --git a/plugins/tesla/skills/python/python-authentication/SKILL.md b/plugins/tesla/skills/python/python-authentication/SKILL.md index 4b770f4e..a0755180 100644 --- a/plugins/tesla/skills/python/python-authentication/SKILL.md +++ b/plugins/tesla/skills/python/python-authentication/SKILL.md @@ -24,7 +24,7 @@ its `{oauth2}_token_source=` override.) The credential classes below live under `{root_package}.core` and are the **same across all APIMatic Python SDKs**; only the **keyword names** differ per SDK — each is the scheme's id, snake_cased (hence -the `{...}` placeholders). +the `{...}` placeholders). One exception: this SDK's `ClientCredentials` and `AuthorizationCodeCredentials` also require `audience`. ## The two spellings @@ -33,8 +33,8 @@ Every credential keyword accepts a typed model or a mapping, and the two produce ```python from {root_package}.core import ClientCredentials -client = {Client}({oauth2}=ClientCredentials(client_id=cid, client_secret=secret)) -client = {Client}({oauth2}={"client_id": cid, "client_secret": secret}) +client = {Client}({oauth2}=ClientCredentials(client_id=cid, client_secret=secret, audience=audience)) +client = {Client}({oauth2}={"client_id": cid, "client_secret": secret, "audience": audience}) ``` Prefer the typed form in application code — it is what your type checker can verify. The dict form is @@ -93,6 +93,7 @@ from {root_package}.core import ClientCredentials client = {Client}({oauth2}=ClientCredentials( client_id="...", client_secret="...", + audience="https://fleet-api.prd.na.vn.cloud.tesla.com", # required — the Fleet API base URL of the token's region scopes=["a", "b"], # optional )) ``` @@ -114,6 +115,7 @@ client = {Client}({oauth2}=AuthorizationCodeCredentials( client_id="...", client_secret="...", # optional; needed only when PKCE is disabled (pkce=None) redirect_uri="https://app.example.com/callback", + audience="https://fleet-api.prd.na.vn.cloud.tesla.com", # required — sent on the code exchange scopes=["a"], # optional state="...", # optional CSRF token pkce="S256", # default; RFC 7636 ("plain" where §7.2 permits it) @@ -165,7 +167,7 @@ is the part that matters: with bad credentials constructs perfectly happily; the failure surfaces at the first operation. - The fetch is a form-encoded `POST` to the token endpoint derived from the client's `base_url`, with the client id and secret sent as HTTP Basic (`client_secret_basic`) or in the form body - (`client_secret_post`), per the scheme. + (`client_secret_post`), per the scheme. The client-credentials request and the authorization-code exchange also send `audience`; a refresh does not. - The resulting token is **cached in memory on the client's auth scheme** and reused across calls, which is the whole reason a client must be long-lived (`python-client-initialization`); a burst of concurrent first calls pays for **one** fetch. diff --git a/plugins/tesla/skills/python/python-getting-started/SKILL.md b/plugins/tesla/skills/python/python-getting-started/SKILL.md index 2e8ac358..c1d9c85e 100644 --- a/plugins/tesla/skills/python/python-getting-started/SKILL.md +++ b/plugins/tesla/skills/python/python-getting-started/SKILL.md @@ -108,8 +108,8 @@ from tesla_fleet_management_api.core import AuthorizationCodeCredentials def prompt(url: str) -> str: return input(f"Open {url}, then paste the code: ") -client = Client(thirdpartytoken_authorization_code=AuthorizationCodeCredentials(client_id="…", client_secret="…", redirect_uri="…", prompt_for_authorization_code=prompt)) -client = Client(thirdpartytoken_authorization_code={"client_id": "…", "client_secret": "…", "redirect_uri": "…", "prompt_for_authorization_code": prompt}) # equivalent +client = Client(thirdpartytoken_authorization_code=AuthorizationCodeCredentials(client_id="…", client_secret="…", redirect_uri="…", audience="https://fleet-api.prd.na.vn.cloud.tesla.com", prompt_for_authorization_code=prompt)) +client = Client(thirdpartytoken_authorization_code={"client_id": "…", "client_secret": "…", "redirect_uri": "…", "audience": "https://fleet-api.prd.na.vn.cloud.tesla.com", "prompt_for_authorization_code": prompt}) # equivalent ``` OAuth 2.0 client credentials, exposed as the client's `thirdpartytoken_client_credentials=` keyword taking `ClientCredentials` **or a plain dict**. The client fetches and caches the bearer token itself, lazily, from `/token` on the `access_token_server` server. @@ -118,8 +118,8 @@ OAuth 2.0 client credentials, exposed as the client's `thirdpartytoken_client_cr from tesla_fleet_management_api import Client from tesla_fleet_management_api.core import ClientCredentials -client = Client(thirdpartytoken_client_credentials=ClientCredentials(client_id="…", client_secret="…")) -client = Client(thirdpartytoken_client_credentials={"client_id": "…", "client_secret": "…"}) # equivalent +client = Client(thirdpartytoken_client_credentials=ClientCredentials(client_id="…", client_secret="…", audience="https://fleet-api.prd.na.vn.cloud.tesla.com")) +client = Client(thirdpartytoken_client_credentials={"client_id": "…", "client_secret": "…", "audience": "https://fleet-api.prd.na.vn.cloud.tesla.com"}) # equivalent ``` **Every credentials keyword is optional** — omit it and requests go out unauthenticated, with nothing failing at construction; `python-authentication` covers how to catch that, and what a *failed token fetch* raises. diff --git a/plugins/tesla/skills/typescript/typescript-authentication/SKILL.md b/plugins/tesla/skills/typescript/typescript-authentication/SKILL.md index c676f732..874f2b67 100644 --- a/plugins/tesla/skills/typescript/typescript-authentication/SKILL.md +++ b/plugins/tesla/skills/typescript/typescript-authentication/SKILL.md @@ -113,6 +113,7 @@ const client = new {Api}Client({ {scheme}: { clientId: process.env.CLIENT_ID!, clientSecret: process.env.CLIENT_SECRET!, // required for this grant + audience: "https://fleet-api.prd.na.vn.cloud.tesla.com", // required — the Fleet API base URL of the token's region scope: "read write", // optional — omit if the API needs none }, }); @@ -139,6 +140,7 @@ const client = new {Api}Client({ clientId: process.env.CLIENT_ID!, clientSecret: process.env.CLIENT_SECRET, // optional — see the note below redirectUri: "https://app.example.com/callback", + audience: "https://fleet-api.prd.na.vn.cloud.tesla.com", // required — sent on the code exchange scope: "read write", // optional state: crypto.randomUUID(), // optional CSRF token pkce: PkceMethod.S256, // default; RFC 7636 diff --git a/plugins/tesla/skills/typescript/typescript-getting-started/SKILL.md b/plugins/tesla/skills/typescript/typescript-getting-started/SKILL.md index ff7b771b..1b0a195b 100644 --- a/plugins/tesla/skills/typescript/typescript-getting-started/SKILL.md +++ b/plugins/tesla/skills/typescript/typescript-getting-started/SKILL.md @@ -84,8 +84,8 @@ Authentication is **per operation**: every operation declares the requirement it ```ts const client = new TeslaFleetManagementApiClient({ bearerAuth: process.env.API_TOKEN!, - thirdpartytokenAuthorizationCode: { clientId: process.env.CLIENT_ID!, redirectUri: process.env.REDIRECT_URI!, promptForAuthorizationCode: async (url) => { /* send the user to url */ return "YOUR_AUTHORIZATION_CODE"; } }, - thirdpartytokenClientCredentials: { clientId: process.env.CLIENT_ID!, clientSecret: process.env.CLIENT_SECRET! }, + thirdpartytokenAuthorizationCode: { clientId: process.env.CLIENT_ID!, redirectUri: process.env.REDIRECT_URI!, audience: "https://fleet-api.prd.na.vn.cloud.tesla.com", promptForAuthorizationCode: async (url) => { /* send the user to url */ return "YOUR_AUTHORIZATION_CODE"; } }, + thirdpartytokenClientCredentials: { clientId: process.env.CLIENT_ID!, clientSecret: process.env.CLIENT_SECRET!, audience: "https://fleet-api.prd.na.vn.cloud.tesla.com" }, }); ``` diff --git a/plugins/tesla/skills/typescript/typescript-testing/SKILL.md b/plugins/tesla/skills/typescript/typescript-testing/SKILL.md index 1a11d09c..fbfc89bf 100644 --- a/plugins/tesla/skills/typescript/typescript-testing/SKILL.md +++ b/plugins/tesla/skills/typescript/typescript-testing/SKILL.md @@ -461,7 +461,7 @@ const stubStrategy = { // keep it a variable: inline, tryRef }; const client = new {Api}Client({ - {scheme}: { clientId: "id", clientSecret: "secret" }, // still required — the scheme is off without it + {scheme}: { clientId: "id", clientSecret: "secret", audience: "https://fleet-api.prd.na.vn.cloud.tesla.com" }, // still required — the scheme is off without it {scheme}Strategy: stubStrategy, fetch: stub.fetch, }); @@ -469,7 +469,7 @@ const client = new {Api}Client({ That credential fits the client-credentials grant. Match `{scheme}`'s type in `src/client-options.ts`: `OAuth2PasswordCredentials` needs `username` and `password`, and `OAuth2AuthorizationCodeCredentials` -needs `redirectUri` and `promptForAuthorizationCode` (e.g. `async () => "code"`). +needs `redirectUri`, `audience` and `promptForAuthorizationCode` (e.g. `async () => "code"`). Facts that make these tests behave: