Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion plugins/tesla/.claude-plugin/plugin.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
2 changes: 1 addition & 1 deletion plugins/tesla/.codex-plugin/plugin.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down
2 changes: 1 addition & 1 deletion plugins/tesla/.cursor-plugin/plugin.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
2 changes: 1 addition & 1 deletion plugins/tesla/plugin.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
8 changes: 6 additions & 2 deletions plugins/tesla/skills/dotnet/dotnet-authentication/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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.

Expand Down Expand Up @@ -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

Expand Down
10 changes: 6 additions & 4 deletions plugins/tesla/skills/python/python-authentication/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand Down Expand Up @@ -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
))
```
Expand All @@ -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)
Expand Down Expand Up @@ -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.
Expand Down
8 changes: 4 additions & 4 deletions plugins/tesla/skills/python/python-getting-started/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
},
});
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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" },
});
```

Expand Down
4 changes: 2 additions & 2 deletions plugins/tesla/skills/typescript/typescript-testing/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -461,15 +461,15 @@ 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,
});
```

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:

Expand Down
Loading