archastro.platform.v1.resources.oauth

  1# Copyright (c) 2026 ArchAstro Inc. Licensed under the MIT License.
  2# This file is auto-generated by @archastro/sdk-generator. Do not edit.
  3# Content hash: 42ce6ede96b6
  4
  5from __future__ import annotations
  6
  7from typing import Any, Required, TypedDict
  8
  9from pydantic import BaseModel, Field
 10
 11from ...runtime.http_client import HttpClient, SyncHttpClient
 12from ...types.device import (
 13    DeviceAuthorizationDetailsResponse,
 14    DeviceAuthorizationResponse,
 15    DeviceAuthorizationStatusResponse,
 16)
 17from ...types.oauth import OAuthTokenResponse
 18
 19
 20class DeviceApproveInput(TypedDict, total=False):
 21    "Approve a device authorization request"
 22
 23    thread: str | None
 24    "Thread ID (`thr_...`) to bind to the authorization. Required when the requested scopes include a thread-scoped permission."
 25    user_code: Required[str]
 26    "User-facing verification code shown on the device. Identifies the pending authorization to approve."
 27
 28
 29class DeviceAuthorizeInput(TypedDict, total=False):
 30    "Initiate a device authorization request"
 31
 32    client: Required[str]
 33    "OAuth client ID (`cli_...`) identifying the application requesting authorization."
 34    scope: str | None
 35    'Space-separated list of OAuth scopes to request, e.g. `"read write"`. Omit to request only the default scopes configured for the client.'
 36
 37
 38class DeviceDenyInput(TypedDict):
 39    "Deny a device authorization request"
 40
 41    user_code: str
 42    "User-facing verification code shown on the device. Identifies the pending authorization to deny."
 43
 44
 45class OauthTokenInput(TypedDict, total=False):
 46    "Exchange a grant for OAuth tokens"
 47
 48    client: str | None
 49    'OAuth client ID identifying the application requesting tokens. Required for `"authorization_code"`, device-code, and resource-bound refresh grants.'
 50    code: str | None
 51    'Single-use authorization code issued by the authorization endpoint. Required for `"authorization_code"` grants.'
 52    code_verifier: str | None
 53    "PKCE code verifier corresponding to the `code_challenge` sent in the authorization request. Required when the authorization code was issued with a code challenge; omit otherwise."
 54    device_code: str | None
 55    "Device code received from the device authorization endpoint. Required for device-code grants."
 56    grant_type: Required[str]
 57    'The OAuth 2.0 grant type. One of `"authorization_code"`, `"refresh_token"`, or `"urn:ietf:params:oauth:grant-type:device_code"`.'
 58    redirect_uri: str | None
 59    'Redirect URI that was used in the original authorization request. Must exactly match the URI on record for the client. Required for `"authorization_code"` grants.'
 60    refresh_token: str | None
 61    'Refresh token received from a previous token response. Required for `"refresh_token"` grants. The token is rotated on each successful call.'
 62    resource: str | None
 63    "Resource audience. Required for code exchange and refresh of a token bound to a resource server; must match the consent grant."
 64
 65
 66class OauthScopesResponse(BaseModel):
 67    """
 68    Successful response
 69    """
 70
 71    scopes: dict[str, Any] = Field(
 72        ...,
 73        description='Map of scope name to its definition object. Each key is a scope string (e.g. `"threads:read"`) and each value describes the scope\'s purpose and requirements.',
 74    )
 75
 76
 77class AsyncDeviceResource:
 78    def __init__(self, http: HttpClient):
 79        self._http = http
 80
 81    async def approve(self, input: DeviceApproveInput) -> DeviceAuthorizationStatusResponse:
 82        """
 83        Approve a device authorization request
 84        Grants the pending device authorization identified by `user_code`, completing
 85        the OAuth Device Authorization flow on behalf of the authenticated user. Once
 86        approved, the device can exchange the `device_code` for an access token.
 87        Requires a valid user session the request must be authenticated as an end
 88        user, not a machine client. The `user_code` must belong to a pending (not
 89        expired, not already approved or denied) authorization associated with the
 90        calling app.
 91        If the requested scopes include a `thread`-scoped permission, you must supply
 92        the `thread` parameter; omitting it returns a 400 with `error: "invalid_scope"`.
 93
 94        Args:
 95            input: Request body.
 96            input.thread: Thread ID (`thr_...`) to bind to the authorization. Required when the requested scopes include a thread-scoped permission.
 97            input.user_code: User-facing verification code shown on the device. Identifies the pending authorization to approve.
 98
 99        Returns:
100            Confirmation that the device authorization was approved. The `status` field will be `"approved"`.
101        """
102        return await self._http.request(
103            "/oauth/device/approve",
104            method="POST",
105            body=input,
106            response_type=DeviceAuthorizationStatusResponse,
107        )
108
109    async def authorization(self, code: str) -> DeviceAuthorizationDetailsResponse:
110        """
111        Inspect a pending device authorization
112        Returns the client name, requested scopes, and expiration for a pending
113        device authorization owned by the calling app. The caller must be an
114        authenticated user. This endpoint never approves the request.
115
116        Args:
117            code: User-facing device authorization code.
118
119        Returns:
120            Successful response
121        """
122        query: dict[str, object] = {}
123        query["code"] = code
124        return await self._http.request(
125            "/oauth/device/authorization",
126            query=query,
127            response_type=DeviceAuthorizationDetailsResponse,
128        )
129
130    async def authorize(self, input: DeviceAuthorizeInput) -> DeviceAuthorizationResponse:
131        """
132        Initiate a device authorization request
133        Starts the OAuth 2.0 Device Authorization flow for a device that cannot
134        perform browser-based redirects. Returns a `device_code` (used by the device
135        to poll for a token) and a `user_code` (shown to the user to enter at the
136        `verification_uri`).
137        This endpoint requires a publishable API key; secret keys are rejected with
138        a 403. Third-party OAuth must be enabled on the app; if it is not, the
139        response returns `error: "third_party_oauth_not_enabled"` with a 403.
140        The endpoint is rate-limited to 10 requests per IP per minute. Excess
141        requests receive a 429 response. The returned codes expire after
142        `expires_in` seconds; once expired, a new authorization request must be
143        initiated.
144
145        Args:
146            input: Request body.
147            input.client: OAuth client ID (`cli_...`) identifying the application requesting authorization.
148            input.scope: Space-separated list of OAuth scopes to request, e.g. `"read write"`. Omit to request only the default scopes configured for the client.
149
150        Returns:
151            Device authorization codes and polling parameters. Present the `user_code` to the user and direct them to `verification_uri`. Poll the token endpoint using `device_code` at the rate given by `interval`.
152        """
153        return await self._http.request(
154            "/oauth/device/authorize",
155            method="POST",
156            body=input,
157            response_type=DeviceAuthorizationResponse,
158        )
159
160    async def deny(self, input: DeviceDenyInput) -> DeviceAuthorizationStatusResponse:
161        """
162        Deny a device authorization request
163        Rejects the pending device authorization identified by `user_code`, preventing
164        the device from obtaining an access token. Once denied, the device will
165        receive an `access_denied` error on its next token poll.
166        Requires a valid user session. The `user_code` must belong to a pending
167        authorization associated with the calling app. Attempting to deny an already
168        approved, already denied, or expired authorization returns a 400.
169
170        Args:
171            input: Request body.
172            input.user_code: User-facing verification code shown on the device. Identifies the pending authorization to deny.
173
174        Returns:
175            Confirmation that the device authorization was denied. The `status` field will be `"denied"`.
176        """
177        return await self._http.request(
178            "/oauth/device/deny",
179            method="POST",
180            body=input,
181            response_type=DeviceAuthorizationStatusResponse,
182        )
183
184
185class AsyncOauthResource:
186    def __init__(self, http: HttpClient):
187        self._http = http
188        self.device = AsyncDeviceResource(http)
189
190    async def scopes(self) -> OauthScopesResponse:
191        """
192        List available OAuth scopes
193        Returns the complete set of OAuth scopes that the platform supports.
194        Use this endpoint to discover which scopes are available before constructing
195        an authorization request or rendering a consent UI.
196        No authentication is required. The response is the same for all callers.
197
198        Returns:
199            Successful response
200        """
201        return await self._http.request("/oauth/scopes", response_type=OauthScopesResponse)
202
203    async def token(self, input: OauthTokenInput) -> OAuthTokenResponse:
204        """
205        Exchange a grant for OAuth tokens
206        Issues an access token and a refresh token in exchange for a valid grant.
207        Three grant types are supported: `"authorization_code"`, `"refresh_token"`,
208        and `"urn:ietf:params:oauth:grant-type:device_code"`.
209        For `"authorization_code"` grants, supply `code`, `client`, `redirect_uri`, and
210        optionally `code_verifier` for PKCE flows. Each authorization code is single-use;
211        consuming it a second time returns `invalid_grant`.
212        For `"refresh_token"` grants, supply `refresh_token`. Resource-bound public
213        clients must also supply `client`. The endpoint rotates the refresh token on
214        every call and returns a fresh pair of tokens.
215        For device-code grants, supply `device_code` and `client`. Poll this endpoint
216        after receiving `authorization_pending` until the user approves or the code
217        expires. Slow down polling if you receive `slow_down`.
218        This endpoint is rate-limited to 20 requests per IP per 60 seconds. Exceeding
219        the limit returns HTTP 429 with `"error": "too_many_requests"`.
220
221        Args:
222            input: Request body.
223            input.client: OAuth client ID identifying the application requesting tokens. Required for `"authorization_code"`, device-code, and resource-bound refresh grants.
224            input.code: Single-use authorization code issued by the authorization endpoint. Required for `"authorization_code"` grants.
225            input.code_verifier: PKCE code verifier corresponding to the `code_challenge` sent in the authorization request. Required when the authorization code was issued with a code challenge; omit otherwise.
226            input.device_code: Device code received from the device authorization endpoint. Required for device-code grants.
227            input.grant_type: The OAuth 2.0 grant type. One of `"authorization_code"`, `"refresh_token"`, or `"urn:ietf:params:oauth:grant-type:device_code"`.
228            input.redirect_uri: Redirect URI that was used in the original authorization request. Must exactly match the URI on record for the client. Required for `"authorization_code"` grants.
229            input.refresh_token: Refresh token received from a previous token response. Required for `"refresh_token"` grants. The token is rotated on each successful call.
230            input.resource: Resource audience. Required for code exchange and refresh of a token bound to a resource server; must match the consent grant.
231
232        Returns:
233            Token pair issued for the authenticated user.
234        """
235        return await self._http.request(
236            "/oauth/token",
237            method="POST",
238            body=input,
239            response_type=OAuthTokenResponse,
240        )
241
242
243class DeviceResource:
244    def __init__(self, http: SyncHttpClient):
245        self._http = http
246
247    def approve(self, input: DeviceApproveInput) -> DeviceAuthorizationStatusResponse:
248        """
249        Approve a device authorization request
250        Grants the pending device authorization identified by `user_code`, completing
251        the OAuth Device Authorization flow on behalf of the authenticated user. Once
252        approved, the device can exchange the `device_code` for an access token.
253        Requires a valid user session the request must be authenticated as an end
254        user, not a machine client. The `user_code` must belong to a pending (not
255        expired, not already approved or denied) authorization associated with the
256        calling app.
257        If the requested scopes include a `thread`-scoped permission, you must supply
258        the `thread` parameter; omitting it returns a 400 with `error: "invalid_scope"`.
259
260        Args:
261            input: Request body.
262            input.thread: Thread ID (`thr_...`) to bind to the authorization. Required when the requested scopes include a thread-scoped permission.
263            input.user_code: User-facing verification code shown on the device. Identifies the pending authorization to approve.
264
265        Returns:
266            Confirmation that the device authorization was approved. The `status` field will be `"approved"`.
267        """
268        return self._http.request(
269            "/oauth/device/approve",
270            method="POST",
271            body=input,
272            response_type=DeviceAuthorizationStatusResponse,
273        )
274
275    def authorization(self, code: str) -> DeviceAuthorizationDetailsResponse:
276        """
277        Inspect a pending device authorization
278        Returns the client name, requested scopes, and expiration for a pending
279        device authorization owned by the calling app. The caller must be an
280        authenticated user. This endpoint never approves the request.
281
282        Args:
283            code: User-facing device authorization code.
284
285        Returns:
286            Successful response
287        """
288        query: dict[str, object] = {}
289        query["code"] = code
290        return self._http.request(
291            "/oauth/device/authorization",
292            query=query,
293            response_type=DeviceAuthorizationDetailsResponse,
294        )
295
296    def authorize(self, input: DeviceAuthorizeInput) -> DeviceAuthorizationResponse:
297        """
298        Initiate a device authorization request
299        Starts the OAuth 2.0 Device Authorization flow for a device that cannot
300        perform browser-based redirects. Returns a `device_code` (used by the device
301        to poll for a token) and a `user_code` (shown to the user to enter at the
302        `verification_uri`).
303        This endpoint requires a publishable API key; secret keys are rejected with
304        a 403. Third-party OAuth must be enabled on the app; if it is not, the
305        response returns `error: "third_party_oauth_not_enabled"` with a 403.
306        The endpoint is rate-limited to 10 requests per IP per minute. Excess
307        requests receive a 429 response. The returned codes expire after
308        `expires_in` seconds; once expired, a new authorization request must be
309        initiated.
310
311        Args:
312            input: Request body.
313            input.client: OAuth client ID (`cli_...`) identifying the application requesting authorization.
314            input.scope: Space-separated list of OAuth scopes to request, e.g. `"read write"`. Omit to request only the default scopes configured for the client.
315
316        Returns:
317            Device authorization codes and polling parameters. Present the `user_code` to the user and direct them to `verification_uri`. Poll the token endpoint using `device_code` at the rate given by `interval`.
318        """
319        return self._http.request(
320            "/oauth/device/authorize",
321            method="POST",
322            body=input,
323            response_type=DeviceAuthorizationResponse,
324        )
325
326    def deny(self, input: DeviceDenyInput) -> DeviceAuthorizationStatusResponse:
327        """
328        Deny a device authorization request
329        Rejects the pending device authorization identified by `user_code`, preventing
330        the device from obtaining an access token. Once denied, the device will
331        receive an `access_denied` error on its next token poll.
332        Requires a valid user session. The `user_code` must belong to a pending
333        authorization associated with the calling app. Attempting to deny an already
334        approved, already denied, or expired authorization returns a 400.
335
336        Args:
337            input: Request body.
338            input.user_code: User-facing verification code shown on the device. Identifies the pending authorization to deny.
339
340        Returns:
341            Confirmation that the device authorization was denied. The `status` field will be `"denied"`.
342        """
343        return self._http.request(
344            "/oauth/device/deny",
345            method="POST",
346            body=input,
347            response_type=DeviceAuthorizationStatusResponse,
348        )
349
350
351class OauthResource:
352    def __init__(self, http: SyncHttpClient):
353        self._http = http
354        self.device = DeviceResource(http)
355
356    def scopes(self) -> OauthScopesResponse:
357        """
358        List available OAuth scopes
359        Returns the complete set of OAuth scopes that the platform supports.
360        Use this endpoint to discover which scopes are available before constructing
361        an authorization request or rendering a consent UI.
362        No authentication is required. The response is the same for all callers.
363
364        Returns:
365            Successful response
366        """
367        return self._http.request("/oauth/scopes", response_type=OauthScopesResponse)
368
369    def token(self, input: OauthTokenInput) -> OAuthTokenResponse:
370        """
371        Exchange a grant for OAuth tokens
372        Issues an access token and a refresh token in exchange for a valid grant.
373        Three grant types are supported: `"authorization_code"`, `"refresh_token"`,
374        and `"urn:ietf:params:oauth:grant-type:device_code"`.
375        For `"authorization_code"` grants, supply `code`, `client`, `redirect_uri`, and
376        optionally `code_verifier` for PKCE flows. Each authorization code is single-use;
377        consuming it a second time returns `invalid_grant`.
378        For `"refresh_token"` grants, supply `refresh_token`. Resource-bound public
379        clients must also supply `client`. The endpoint rotates the refresh token on
380        every call and returns a fresh pair of tokens.
381        For device-code grants, supply `device_code` and `client`. Poll this endpoint
382        after receiving `authorization_pending` until the user approves or the code
383        expires. Slow down polling if you receive `slow_down`.
384        This endpoint is rate-limited to 20 requests per IP per 60 seconds. Exceeding
385        the limit returns HTTP 429 with `"error": "too_many_requests"`.
386
387        Args:
388            input: Request body.
389            input.client: OAuth client ID identifying the application requesting tokens. Required for `"authorization_code"`, device-code, and resource-bound refresh grants.
390            input.code: Single-use authorization code issued by the authorization endpoint. Required for `"authorization_code"` grants.
391            input.code_verifier: PKCE code verifier corresponding to the `code_challenge` sent in the authorization request. Required when the authorization code was issued with a code challenge; omit otherwise.
392            input.device_code: Device code received from the device authorization endpoint. Required for device-code grants.
393            input.grant_type: The OAuth 2.0 grant type. One of `"authorization_code"`, `"refresh_token"`, or `"urn:ietf:params:oauth:grant-type:device_code"`.
394            input.redirect_uri: Redirect URI that was used in the original authorization request. Must exactly match the URI on record for the client. Required for `"authorization_code"` grants.
395            input.refresh_token: Refresh token received from a previous token response. Required for `"refresh_token"` grants. The token is rotated on each successful call.
396            input.resource: Resource audience. Required for code exchange and refresh of a token bound to a resource server; must match the consent grant.
397
398        Returns:
399            Token pair issued for the authenticated user.
400        """
401        return self._http.request(
402            "/oauth/token",
403            method="POST",
404            body=input,
405            response_type=OAuthTokenResponse,
406        )
class DeviceApproveInput(typing.TypedDict):
21class DeviceApproveInput(TypedDict, total=False):
22    "Approve a device authorization request"
23
24    thread: str | None
25    "Thread ID (`thr_...`) to bind to the authorization. Required when the requested scopes include a thread-scoped permission."
26    user_code: Required[str]
27    "User-facing verification code shown on the device. Identifies the pending authorization to approve."

Approve a device authorization request

thread: str | None

Thread ID (thr_...) to bind to the authorization. Required when the requested scopes include a thread-scoped permission.

user_code: Required[str]

User-facing verification code shown on the device. Identifies the pending authorization to approve.

class DeviceAuthorizeInput(typing.TypedDict):
30class DeviceAuthorizeInput(TypedDict, total=False):
31    "Initiate a device authorization request"
32
33    client: Required[str]
34    "OAuth client ID (`cli_...`) identifying the application requesting authorization."
35    scope: str | None
36    'Space-separated list of OAuth scopes to request, e.g. `"read write"`. Omit to request only the default scopes configured for the client.'

Initiate a device authorization request

client: Required[str]

OAuth client ID (cli_...) identifying the application requesting authorization.

scope: str | None

Space-separated list of OAuth scopes to request, e.g. "read write". Omit to request only the default scopes configured for the client.

class DeviceDenyInput(typing.TypedDict):
39class DeviceDenyInput(TypedDict):
40    "Deny a device authorization request"
41
42    user_code: str
43    "User-facing verification code shown on the device. Identifies the pending authorization to deny."

Deny a device authorization request

user_code: str

User-facing verification code shown on the device. Identifies the pending authorization to deny.

class OauthTokenInput(typing.TypedDict):
46class OauthTokenInput(TypedDict, total=False):
47    "Exchange a grant for OAuth tokens"
48
49    client: str | None
50    'OAuth client ID identifying the application requesting tokens. Required for `"authorization_code"`, device-code, and resource-bound refresh grants.'
51    code: str | None
52    'Single-use authorization code issued by the authorization endpoint. Required for `"authorization_code"` grants.'
53    code_verifier: str | None
54    "PKCE code verifier corresponding to the `code_challenge` sent in the authorization request. Required when the authorization code was issued with a code challenge; omit otherwise."
55    device_code: str | None
56    "Device code received from the device authorization endpoint. Required for device-code grants."
57    grant_type: Required[str]
58    'The OAuth 2.0 grant type. One of `"authorization_code"`, `"refresh_token"`, or `"urn:ietf:params:oauth:grant-type:device_code"`.'
59    redirect_uri: str | None
60    'Redirect URI that was used in the original authorization request. Must exactly match the URI on record for the client. Required for `"authorization_code"` grants.'
61    refresh_token: str | None
62    'Refresh token received from a previous token response. Required for `"refresh_token"` grants. The token is rotated on each successful call.'
63    resource: str | None
64    "Resource audience. Required for code exchange and refresh of a token bound to a resource server; must match the consent grant."

Exchange a grant for OAuth tokens

client: str | None

OAuth client ID identifying the application requesting tokens. Required for "authorization_code", device-code, and resource-bound refresh grants.

code: str | None

Single-use authorization code issued by the authorization endpoint. Required for "authorization_code" grants.

code_verifier: str | None

PKCE code verifier corresponding to the code_challenge sent in the authorization request. Required when the authorization code was issued with a code challenge; omit otherwise.

device_code: str | None

Device code received from the device authorization endpoint. Required for device-code grants.

grant_type: Required[str]

The OAuth 2.0 grant type. One of "authorization_code", "refresh_token", or "urn:ietf:params:oauth:grant-type:device_code".

redirect_uri: str | None

Redirect URI that was used in the original authorization request. Must exactly match the URI on record for the client. Required for "authorization_code" grants.

refresh_token: str | None

Refresh token received from a previous token response. Required for "refresh_token" grants. The token is rotated on each successful call.

resource: str | None

Resource audience. Required for code exchange and refresh of a token bound to a resource server; must match the consent grant.

class OauthScopesResponse(pydantic.main.BaseModel):
67class OauthScopesResponse(BaseModel):
68    """
69    Successful response
70    """
71
72    scopes: dict[str, Any] = Field(
73        ...,
74        description='Map of scope name to its definition object. Each key is a scope string (e.g. `"threads:read"`) and each value describes the scope\'s purpose and requirements.',
75    )

Successful response

scopes: dict[str, typing.Any] = PydanticUndefined

Map of scope name to its definition object. Each key is a scope string (e.g. "threads:read") and each value describes the scope's purpose and requirements.

class AsyncDeviceResource:
 78class AsyncDeviceResource:
 79    def __init__(self, http: HttpClient):
 80        self._http = http
 81
 82    async def approve(self, input: DeviceApproveInput) -> DeviceAuthorizationStatusResponse:
 83        """
 84        Approve a device authorization request
 85        Grants the pending device authorization identified by `user_code`, completing
 86        the OAuth Device Authorization flow on behalf of the authenticated user. Once
 87        approved, the device can exchange the `device_code` for an access token.
 88        Requires a valid user session the request must be authenticated as an end
 89        user, not a machine client. The `user_code` must belong to a pending (not
 90        expired, not already approved or denied) authorization associated with the
 91        calling app.
 92        If the requested scopes include a `thread`-scoped permission, you must supply
 93        the `thread` parameter; omitting it returns a 400 with `error: "invalid_scope"`.
 94
 95        Args:
 96            input: Request body.
 97            input.thread: Thread ID (`thr_...`) to bind to the authorization. Required when the requested scopes include a thread-scoped permission.
 98            input.user_code: User-facing verification code shown on the device. Identifies the pending authorization to approve.
 99
100        Returns:
101            Confirmation that the device authorization was approved. The `status` field will be `"approved"`.
102        """
103        return await self._http.request(
104            "/oauth/device/approve",
105            method="POST",
106            body=input,
107            response_type=DeviceAuthorizationStatusResponse,
108        )
109
110    async def authorization(self, code: str) -> DeviceAuthorizationDetailsResponse:
111        """
112        Inspect a pending device authorization
113        Returns the client name, requested scopes, and expiration for a pending
114        device authorization owned by the calling app. The caller must be an
115        authenticated user. This endpoint never approves the request.
116
117        Args:
118            code: User-facing device authorization code.
119
120        Returns:
121            Successful response
122        """
123        query: dict[str, object] = {}
124        query["code"] = code
125        return await self._http.request(
126            "/oauth/device/authorization",
127            query=query,
128            response_type=DeviceAuthorizationDetailsResponse,
129        )
130
131    async def authorize(self, input: DeviceAuthorizeInput) -> DeviceAuthorizationResponse:
132        """
133        Initiate a device authorization request
134        Starts the OAuth 2.0 Device Authorization flow for a device that cannot
135        perform browser-based redirects. Returns a `device_code` (used by the device
136        to poll for a token) and a `user_code` (shown to the user to enter at the
137        `verification_uri`).
138        This endpoint requires a publishable API key; secret keys are rejected with
139        a 403. Third-party OAuth must be enabled on the app; if it is not, the
140        response returns `error: "third_party_oauth_not_enabled"` with a 403.
141        The endpoint is rate-limited to 10 requests per IP per minute. Excess
142        requests receive a 429 response. The returned codes expire after
143        `expires_in` seconds; once expired, a new authorization request must be
144        initiated.
145
146        Args:
147            input: Request body.
148            input.client: OAuth client ID (`cli_...`) identifying the application requesting authorization.
149            input.scope: Space-separated list of OAuth scopes to request, e.g. `"read write"`. Omit to request only the default scopes configured for the client.
150
151        Returns:
152            Device authorization codes and polling parameters. Present the `user_code` to the user and direct them to `verification_uri`. Poll the token endpoint using `device_code` at the rate given by `interval`.
153        """
154        return await self._http.request(
155            "/oauth/device/authorize",
156            method="POST",
157            body=input,
158            response_type=DeviceAuthorizationResponse,
159        )
160
161    async def deny(self, input: DeviceDenyInput) -> DeviceAuthorizationStatusResponse:
162        """
163        Deny a device authorization request
164        Rejects the pending device authorization identified by `user_code`, preventing
165        the device from obtaining an access token. Once denied, the device will
166        receive an `access_denied` error on its next token poll.
167        Requires a valid user session. The `user_code` must belong to a pending
168        authorization associated with the calling app. Attempting to deny an already
169        approved, already denied, or expired authorization returns a 400.
170
171        Args:
172            input: Request body.
173            input.user_code: User-facing verification code shown on the device. Identifies the pending authorization to deny.
174
175        Returns:
176            Confirmation that the device authorization was denied. The `status` field will be `"denied"`.
177        """
178        return await self._http.request(
179            "/oauth/device/deny",
180            method="POST",
181            body=input,
182            response_type=DeviceAuthorizationStatusResponse,
183        )
AsyncDeviceResource(http: archastro.platform.runtime.http_client.HttpClient)
79    def __init__(self, http: HttpClient):
80        self._http = http
 82    async def approve(self, input: DeviceApproveInput) -> DeviceAuthorizationStatusResponse:
 83        """
 84        Approve a device authorization request
 85        Grants the pending device authorization identified by `user_code`, completing
 86        the OAuth Device Authorization flow on behalf of the authenticated user. Once
 87        approved, the device can exchange the `device_code` for an access token.
 88        Requires a valid user session the request must be authenticated as an end
 89        user, not a machine client. The `user_code` must belong to a pending (not
 90        expired, not already approved or denied) authorization associated with the
 91        calling app.
 92        If the requested scopes include a `thread`-scoped permission, you must supply
 93        the `thread` parameter; omitting it returns a 400 with `error: "invalid_scope"`.
 94
 95        Args:
 96            input: Request body.
 97            input.thread: Thread ID (`thr_...`) to bind to the authorization. Required when the requested scopes include a thread-scoped permission.
 98            input.user_code: User-facing verification code shown on the device. Identifies the pending authorization to approve.
 99
100        Returns:
101            Confirmation that the device authorization was approved. The `status` field will be `"approved"`.
102        """
103        return await self._http.request(
104            "/oauth/device/approve",
105            method="POST",
106            body=input,
107            response_type=DeviceAuthorizationStatusResponse,
108        )

Approve a device authorization request Grants the pending device authorization identified by user_code, completing the OAuth Device Authorization flow on behalf of the authenticated user. Once approved, the device can exchange the device_code for an access token. Requires a valid user session the request must be authenticated as an end user, not a machine client. The user_code must belong to a pending (not expired, not already approved or denied) authorization associated with the calling app. If the requested scopes include a thread-scoped permission, you must supply the thread parameter; omitting it returns a 400 with error: "invalid_scope".

Arguments:
  • input: Request body.
  • input.thread: Thread ID (thr_...) to bind to the authorization. Required when the requested scopes include a thread-scoped permission.
  • input.user_code: User-facing verification code shown on the device. Identifies the pending authorization to approve.
Returns:

Confirmation that the device authorization was approved. The status field will be "approved".

async def authorization( self, code: str) -> archastro.platform.types.device.DeviceAuthorizationDetailsResponse:
110    async def authorization(self, code: str) -> DeviceAuthorizationDetailsResponse:
111        """
112        Inspect a pending device authorization
113        Returns the client name, requested scopes, and expiration for a pending
114        device authorization owned by the calling app. The caller must be an
115        authenticated user. This endpoint never approves the request.
116
117        Args:
118            code: User-facing device authorization code.
119
120        Returns:
121            Successful response
122        """
123        query: dict[str, object] = {}
124        query["code"] = code
125        return await self._http.request(
126            "/oauth/device/authorization",
127            query=query,
128            response_type=DeviceAuthorizationDetailsResponse,
129        )

Inspect a pending device authorization Returns the client name, requested scopes, and expiration for a pending device authorization owned by the calling app. The caller must be an authenticated user. This endpoint never approves the request.

Arguments:
  • code: User-facing device authorization code.
Returns:

Successful response

async def authorize( self, input: DeviceAuthorizeInput) -> archastro.platform.types.device.DeviceAuthorizationResponse:
131    async def authorize(self, input: DeviceAuthorizeInput) -> DeviceAuthorizationResponse:
132        """
133        Initiate a device authorization request
134        Starts the OAuth 2.0 Device Authorization flow for a device that cannot
135        perform browser-based redirects. Returns a `device_code` (used by the device
136        to poll for a token) and a `user_code` (shown to the user to enter at the
137        `verification_uri`).
138        This endpoint requires a publishable API key; secret keys are rejected with
139        a 403. Third-party OAuth must be enabled on the app; if it is not, the
140        response returns `error: "third_party_oauth_not_enabled"` with a 403.
141        The endpoint is rate-limited to 10 requests per IP per minute. Excess
142        requests receive a 429 response. The returned codes expire after
143        `expires_in` seconds; once expired, a new authorization request must be
144        initiated.
145
146        Args:
147            input: Request body.
148            input.client: OAuth client ID (`cli_...`) identifying the application requesting authorization.
149            input.scope: Space-separated list of OAuth scopes to request, e.g. `"read write"`. Omit to request only the default scopes configured for the client.
150
151        Returns:
152            Device authorization codes and polling parameters. Present the `user_code` to the user and direct them to `verification_uri`. Poll the token endpoint using `device_code` at the rate given by `interval`.
153        """
154        return await self._http.request(
155            "/oauth/device/authorize",
156            method="POST",
157            body=input,
158            response_type=DeviceAuthorizationResponse,
159        )

Initiate a device authorization request Starts the OAuth 2.0 Device Authorization flow for a device that cannot perform browser-based redirects. Returns a device_code (used by the device to poll for a token) and a user_code (shown to the user to enter at the verification_uri). This endpoint requires a publishable API key; secret keys are rejected with a 403. Third-party OAuth must be enabled on the app; if it is not, the response returns error: "third_party_oauth_not_enabled" with a 403. The endpoint is rate-limited to 10 requests per IP per minute. Excess requests receive a 429 response. The returned codes expire after expires_in seconds; once expired, a new authorization request must be initiated.

Arguments:
  • input: Request body.
  • input.client: OAuth client ID (cli_...) identifying the application requesting authorization.
  • input.scope: Space-separated list of OAuth scopes to request, e.g. "read write". Omit to request only the default scopes configured for the client.
Returns:

Device authorization codes and polling parameters. Present the user_code to the user and direct them to verification_uri. Poll the token endpoint using device_code at the rate given by interval.

161    async def deny(self, input: DeviceDenyInput) -> DeviceAuthorizationStatusResponse:
162        """
163        Deny a device authorization request
164        Rejects the pending device authorization identified by `user_code`, preventing
165        the device from obtaining an access token. Once denied, the device will
166        receive an `access_denied` error on its next token poll.
167        Requires a valid user session. The `user_code` must belong to a pending
168        authorization associated with the calling app. Attempting to deny an already
169        approved, already denied, or expired authorization returns a 400.
170
171        Args:
172            input: Request body.
173            input.user_code: User-facing verification code shown on the device. Identifies the pending authorization to deny.
174
175        Returns:
176            Confirmation that the device authorization was denied. The `status` field will be `"denied"`.
177        """
178        return await self._http.request(
179            "/oauth/device/deny",
180            method="POST",
181            body=input,
182            response_type=DeviceAuthorizationStatusResponse,
183        )

Deny a device authorization request Rejects the pending device authorization identified by user_code, preventing the device from obtaining an access token. Once denied, the device will receive an access_denied error on its next token poll. Requires a valid user session. The user_code must belong to a pending authorization associated with the calling app. Attempting to deny an already approved, already denied, or expired authorization returns a 400.

Arguments:
  • input: Request body.
  • input.user_code: User-facing verification code shown on the device. Identifies the pending authorization to deny.
Returns:

Confirmation that the device authorization was denied. The status field will be "denied".

class AsyncOauthResource:
186class AsyncOauthResource:
187    def __init__(self, http: HttpClient):
188        self._http = http
189        self.device = AsyncDeviceResource(http)
190
191    async def scopes(self) -> OauthScopesResponse:
192        """
193        List available OAuth scopes
194        Returns the complete set of OAuth scopes that the platform supports.
195        Use this endpoint to discover which scopes are available before constructing
196        an authorization request or rendering a consent UI.
197        No authentication is required. The response is the same for all callers.
198
199        Returns:
200            Successful response
201        """
202        return await self._http.request("/oauth/scopes", response_type=OauthScopesResponse)
203
204    async def token(self, input: OauthTokenInput) -> OAuthTokenResponse:
205        """
206        Exchange a grant for OAuth tokens
207        Issues an access token and a refresh token in exchange for a valid grant.
208        Three grant types are supported: `"authorization_code"`, `"refresh_token"`,
209        and `"urn:ietf:params:oauth:grant-type:device_code"`.
210        For `"authorization_code"` grants, supply `code`, `client`, `redirect_uri`, and
211        optionally `code_verifier` for PKCE flows. Each authorization code is single-use;
212        consuming it a second time returns `invalid_grant`.
213        For `"refresh_token"` grants, supply `refresh_token`. Resource-bound public
214        clients must also supply `client`. The endpoint rotates the refresh token on
215        every call and returns a fresh pair of tokens.
216        For device-code grants, supply `device_code` and `client`. Poll this endpoint
217        after receiving `authorization_pending` until the user approves or the code
218        expires. Slow down polling if you receive `slow_down`.
219        This endpoint is rate-limited to 20 requests per IP per 60 seconds. Exceeding
220        the limit returns HTTP 429 with `"error": "too_many_requests"`.
221
222        Args:
223            input: Request body.
224            input.client: OAuth client ID identifying the application requesting tokens. Required for `"authorization_code"`, device-code, and resource-bound refresh grants.
225            input.code: Single-use authorization code issued by the authorization endpoint. Required for `"authorization_code"` grants.
226            input.code_verifier: PKCE code verifier corresponding to the `code_challenge` sent in the authorization request. Required when the authorization code was issued with a code challenge; omit otherwise.
227            input.device_code: Device code received from the device authorization endpoint. Required for device-code grants.
228            input.grant_type: The OAuth 2.0 grant type. One of `"authorization_code"`, `"refresh_token"`, or `"urn:ietf:params:oauth:grant-type:device_code"`.
229            input.redirect_uri: Redirect URI that was used in the original authorization request. Must exactly match the URI on record for the client. Required for `"authorization_code"` grants.
230            input.refresh_token: Refresh token received from a previous token response. Required for `"refresh_token"` grants. The token is rotated on each successful call.
231            input.resource: Resource audience. Required for code exchange and refresh of a token bound to a resource server; must match the consent grant.
232
233        Returns:
234            Token pair issued for the authenticated user.
235        """
236        return await self._http.request(
237            "/oauth/token",
238            method="POST",
239            body=input,
240            response_type=OAuthTokenResponse,
241        )
AsyncOauthResource(http: archastro.platform.runtime.http_client.HttpClient)
187    def __init__(self, http: HttpClient):
188        self._http = http
189        self.device = AsyncDeviceResource(http)
device
async def scopes(self) -> OauthScopesResponse:
191    async def scopes(self) -> OauthScopesResponse:
192        """
193        List available OAuth scopes
194        Returns the complete set of OAuth scopes that the platform supports.
195        Use this endpoint to discover which scopes are available before constructing
196        an authorization request or rendering a consent UI.
197        No authentication is required. The response is the same for all callers.
198
199        Returns:
200            Successful response
201        """
202        return await self._http.request("/oauth/scopes", response_type=OauthScopesResponse)

List available OAuth scopes Returns the complete set of OAuth scopes that the platform supports. Use this endpoint to discover which scopes are available before constructing an authorization request or rendering a consent UI. No authentication is required. The response is the same for all callers.

Returns:

Successful response

async def token( self, input: OauthTokenInput) -> archastro.platform.types.oauth.OAuthTokenResponse:
204    async def token(self, input: OauthTokenInput) -> OAuthTokenResponse:
205        """
206        Exchange a grant for OAuth tokens
207        Issues an access token and a refresh token in exchange for a valid grant.
208        Three grant types are supported: `"authorization_code"`, `"refresh_token"`,
209        and `"urn:ietf:params:oauth:grant-type:device_code"`.
210        For `"authorization_code"` grants, supply `code`, `client`, `redirect_uri`, and
211        optionally `code_verifier` for PKCE flows. Each authorization code is single-use;
212        consuming it a second time returns `invalid_grant`.
213        For `"refresh_token"` grants, supply `refresh_token`. Resource-bound public
214        clients must also supply `client`. The endpoint rotates the refresh token on
215        every call and returns a fresh pair of tokens.
216        For device-code grants, supply `device_code` and `client`. Poll this endpoint
217        after receiving `authorization_pending` until the user approves or the code
218        expires. Slow down polling if you receive `slow_down`.
219        This endpoint is rate-limited to 20 requests per IP per 60 seconds. Exceeding
220        the limit returns HTTP 429 with `"error": "too_many_requests"`.
221
222        Args:
223            input: Request body.
224            input.client: OAuth client ID identifying the application requesting tokens. Required for `"authorization_code"`, device-code, and resource-bound refresh grants.
225            input.code: Single-use authorization code issued by the authorization endpoint. Required for `"authorization_code"` grants.
226            input.code_verifier: PKCE code verifier corresponding to the `code_challenge` sent in the authorization request. Required when the authorization code was issued with a code challenge; omit otherwise.
227            input.device_code: Device code received from the device authorization endpoint. Required for device-code grants.
228            input.grant_type: The OAuth 2.0 grant type. One of `"authorization_code"`, `"refresh_token"`, or `"urn:ietf:params:oauth:grant-type:device_code"`.
229            input.redirect_uri: Redirect URI that was used in the original authorization request. Must exactly match the URI on record for the client. Required for `"authorization_code"` grants.
230            input.refresh_token: Refresh token received from a previous token response. Required for `"refresh_token"` grants. The token is rotated on each successful call.
231            input.resource: Resource audience. Required for code exchange and refresh of a token bound to a resource server; must match the consent grant.
232
233        Returns:
234            Token pair issued for the authenticated user.
235        """
236        return await self._http.request(
237            "/oauth/token",
238            method="POST",
239            body=input,
240            response_type=OAuthTokenResponse,
241        )

Exchange a grant for OAuth tokens Issues an access token and a refresh token in exchange for a valid grant. Three grant types are supported: "authorization_code", "refresh_token", and "urn:ietf:params:oauth:grant-type:device_code". For "authorization_code" grants, supply code, client, redirect_uri, and optionally code_verifier for PKCE flows. Each authorization code is single-use; consuming it a second time returns invalid_grant. For "refresh_token" grants, supply refresh_token. Resource-bound public clients must also supply client. The endpoint rotates the refresh token on every call and returns a fresh pair of tokens. For device-code grants, supply device_code and client. Poll this endpoint after receiving authorization_pending until the user approves or the code expires. Slow down polling if you receive slow_down. This endpoint is rate-limited to 20 requests per IP per 60 seconds. Exceeding the limit returns HTTP 429 with "error": "too_many_requests".

Arguments:
  • input: Request body.
  • input.client: OAuth client ID identifying the application requesting tokens. Required for "authorization_code", device-code, and resource-bound refresh grants.
  • input.code: Single-use authorization code issued by the authorization endpoint. Required for "authorization_code" grants.
  • input.code_verifier: PKCE code verifier corresponding to the code_challenge sent in the authorization request. Required when the authorization code was issued with a code challenge; omit otherwise.
  • input.device_code: Device code received from the device authorization endpoint. Required for device-code grants.
  • input.grant_type: The OAuth 2.0 grant type. One of "authorization_code", "refresh_token", or "urn:ietf:params:oauth:grant-type:device_code".
  • input.redirect_uri: Redirect URI that was used in the original authorization request. Must exactly match the URI on record for the client. Required for "authorization_code" grants.
  • input.refresh_token: Refresh token received from a previous token response. Required for "refresh_token" grants. The token is rotated on each successful call.
  • input.resource: Resource audience. Required for code exchange and refresh of a token bound to a resource server; must match the consent grant.
Returns:

Token pair issued for the authenticated user.

class DeviceResource:
244class DeviceResource:
245    def __init__(self, http: SyncHttpClient):
246        self._http = http
247
248    def approve(self, input: DeviceApproveInput) -> DeviceAuthorizationStatusResponse:
249        """
250        Approve a device authorization request
251        Grants the pending device authorization identified by `user_code`, completing
252        the OAuth Device Authorization flow on behalf of the authenticated user. Once
253        approved, the device can exchange the `device_code` for an access token.
254        Requires a valid user session the request must be authenticated as an end
255        user, not a machine client. The `user_code` must belong to a pending (not
256        expired, not already approved or denied) authorization associated with the
257        calling app.
258        If the requested scopes include a `thread`-scoped permission, you must supply
259        the `thread` parameter; omitting it returns a 400 with `error: "invalid_scope"`.
260
261        Args:
262            input: Request body.
263            input.thread: Thread ID (`thr_...`) to bind to the authorization. Required when the requested scopes include a thread-scoped permission.
264            input.user_code: User-facing verification code shown on the device. Identifies the pending authorization to approve.
265
266        Returns:
267            Confirmation that the device authorization was approved. The `status` field will be `"approved"`.
268        """
269        return self._http.request(
270            "/oauth/device/approve",
271            method="POST",
272            body=input,
273            response_type=DeviceAuthorizationStatusResponse,
274        )
275
276    def authorization(self, code: str) -> DeviceAuthorizationDetailsResponse:
277        """
278        Inspect a pending device authorization
279        Returns the client name, requested scopes, and expiration for a pending
280        device authorization owned by the calling app. The caller must be an
281        authenticated user. This endpoint never approves the request.
282
283        Args:
284            code: User-facing device authorization code.
285
286        Returns:
287            Successful response
288        """
289        query: dict[str, object] = {}
290        query["code"] = code
291        return self._http.request(
292            "/oauth/device/authorization",
293            query=query,
294            response_type=DeviceAuthorizationDetailsResponse,
295        )
296
297    def authorize(self, input: DeviceAuthorizeInput) -> DeviceAuthorizationResponse:
298        """
299        Initiate a device authorization request
300        Starts the OAuth 2.0 Device Authorization flow for a device that cannot
301        perform browser-based redirects. Returns a `device_code` (used by the device
302        to poll for a token) and a `user_code` (shown to the user to enter at the
303        `verification_uri`).
304        This endpoint requires a publishable API key; secret keys are rejected with
305        a 403. Third-party OAuth must be enabled on the app; if it is not, the
306        response returns `error: "third_party_oauth_not_enabled"` with a 403.
307        The endpoint is rate-limited to 10 requests per IP per minute. Excess
308        requests receive a 429 response. The returned codes expire after
309        `expires_in` seconds; once expired, a new authorization request must be
310        initiated.
311
312        Args:
313            input: Request body.
314            input.client: OAuth client ID (`cli_...`) identifying the application requesting authorization.
315            input.scope: Space-separated list of OAuth scopes to request, e.g. `"read write"`. Omit to request only the default scopes configured for the client.
316
317        Returns:
318            Device authorization codes and polling parameters. Present the `user_code` to the user and direct them to `verification_uri`. Poll the token endpoint using `device_code` at the rate given by `interval`.
319        """
320        return self._http.request(
321            "/oauth/device/authorize",
322            method="POST",
323            body=input,
324            response_type=DeviceAuthorizationResponse,
325        )
326
327    def deny(self, input: DeviceDenyInput) -> DeviceAuthorizationStatusResponse:
328        """
329        Deny a device authorization request
330        Rejects the pending device authorization identified by `user_code`, preventing
331        the device from obtaining an access token. Once denied, the device will
332        receive an `access_denied` error on its next token poll.
333        Requires a valid user session. The `user_code` must belong to a pending
334        authorization associated with the calling app. Attempting to deny an already
335        approved, already denied, or expired authorization returns a 400.
336
337        Args:
338            input: Request body.
339            input.user_code: User-facing verification code shown on the device. Identifies the pending authorization to deny.
340
341        Returns:
342            Confirmation that the device authorization was denied. The `status` field will be `"denied"`.
343        """
344        return self._http.request(
345            "/oauth/device/deny",
346            method="POST",
347            body=input,
348            response_type=DeviceAuthorizationStatusResponse,
349        )
DeviceResource(http: archastro.platform.runtime.http_client.SyncHttpClient)
245    def __init__(self, http: SyncHttpClient):
246        self._http = http
248    def approve(self, input: DeviceApproveInput) -> DeviceAuthorizationStatusResponse:
249        """
250        Approve a device authorization request
251        Grants the pending device authorization identified by `user_code`, completing
252        the OAuth Device Authorization flow on behalf of the authenticated user. Once
253        approved, the device can exchange the `device_code` for an access token.
254        Requires a valid user session the request must be authenticated as an end
255        user, not a machine client. The `user_code` must belong to a pending (not
256        expired, not already approved or denied) authorization associated with the
257        calling app.
258        If the requested scopes include a `thread`-scoped permission, you must supply
259        the `thread` parameter; omitting it returns a 400 with `error: "invalid_scope"`.
260
261        Args:
262            input: Request body.
263            input.thread: Thread ID (`thr_...`) to bind to the authorization. Required when the requested scopes include a thread-scoped permission.
264            input.user_code: User-facing verification code shown on the device. Identifies the pending authorization to approve.
265
266        Returns:
267            Confirmation that the device authorization was approved. The `status` field will be `"approved"`.
268        """
269        return self._http.request(
270            "/oauth/device/approve",
271            method="POST",
272            body=input,
273            response_type=DeviceAuthorizationStatusResponse,
274        )

Approve a device authorization request Grants the pending device authorization identified by user_code, completing the OAuth Device Authorization flow on behalf of the authenticated user. Once approved, the device can exchange the device_code for an access token. Requires a valid user session the request must be authenticated as an end user, not a machine client. The user_code must belong to a pending (not expired, not already approved or denied) authorization associated with the calling app. If the requested scopes include a thread-scoped permission, you must supply the thread parameter; omitting it returns a 400 with error: "invalid_scope".

Arguments:
  • input: Request body.
  • input.thread: Thread ID (thr_...) to bind to the authorization. Required when the requested scopes include a thread-scoped permission.
  • input.user_code: User-facing verification code shown on the device. Identifies the pending authorization to approve.
Returns:

Confirmation that the device authorization was approved. The status field will be "approved".

def authorization( self, code: str) -> archastro.platform.types.device.DeviceAuthorizationDetailsResponse:
276    def authorization(self, code: str) -> DeviceAuthorizationDetailsResponse:
277        """
278        Inspect a pending device authorization
279        Returns the client name, requested scopes, and expiration for a pending
280        device authorization owned by the calling app. The caller must be an
281        authenticated user. This endpoint never approves the request.
282
283        Args:
284            code: User-facing device authorization code.
285
286        Returns:
287            Successful response
288        """
289        query: dict[str, object] = {}
290        query["code"] = code
291        return self._http.request(
292            "/oauth/device/authorization",
293            query=query,
294            response_type=DeviceAuthorizationDetailsResponse,
295        )

Inspect a pending device authorization Returns the client name, requested scopes, and expiration for a pending device authorization owned by the calling app. The caller must be an authenticated user. This endpoint never approves the request.

Arguments:
  • code: User-facing device authorization code.
Returns:

Successful response

297    def authorize(self, input: DeviceAuthorizeInput) -> DeviceAuthorizationResponse:
298        """
299        Initiate a device authorization request
300        Starts the OAuth 2.0 Device Authorization flow for a device that cannot
301        perform browser-based redirects. Returns a `device_code` (used by the device
302        to poll for a token) and a `user_code` (shown to the user to enter at the
303        `verification_uri`).
304        This endpoint requires a publishable API key; secret keys are rejected with
305        a 403. Third-party OAuth must be enabled on the app; if it is not, the
306        response returns `error: "third_party_oauth_not_enabled"` with a 403.
307        The endpoint is rate-limited to 10 requests per IP per minute. Excess
308        requests receive a 429 response. The returned codes expire after
309        `expires_in` seconds; once expired, a new authorization request must be
310        initiated.
311
312        Args:
313            input: Request body.
314            input.client: OAuth client ID (`cli_...`) identifying the application requesting authorization.
315            input.scope: Space-separated list of OAuth scopes to request, e.g. `"read write"`. Omit to request only the default scopes configured for the client.
316
317        Returns:
318            Device authorization codes and polling parameters. Present the `user_code` to the user and direct them to `verification_uri`. Poll the token endpoint using `device_code` at the rate given by `interval`.
319        """
320        return self._http.request(
321            "/oauth/device/authorize",
322            method="POST",
323            body=input,
324            response_type=DeviceAuthorizationResponse,
325        )

Initiate a device authorization request Starts the OAuth 2.0 Device Authorization flow for a device that cannot perform browser-based redirects. Returns a device_code (used by the device to poll for a token) and a user_code (shown to the user to enter at the verification_uri). This endpoint requires a publishable API key; secret keys are rejected with a 403. Third-party OAuth must be enabled on the app; if it is not, the response returns error: "third_party_oauth_not_enabled" with a 403. The endpoint is rate-limited to 10 requests per IP per minute. Excess requests receive a 429 response. The returned codes expire after expires_in seconds; once expired, a new authorization request must be initiated.

Arguments:
  • input: Request body.
  • input.client: OAuth client ID (cli_...) identifying the application requesting authorization.
  • input.scope: Space-separated list of OAuth scopes to request, e.g. "read write". Omit to request only the default scopes configured for the client.
Returns:

Device authorization codes and polling parameters. Present the user_code to the user and direct them to verification_uri. Poll the token endpoint using device_code at the rate given by interval.

327    def deny(self, input: DeviceDenyInput) -> DeviceAuthorizationStatusResponse:
328        """
329        Deny a device authorization request
330        Rejects the pending device authorization identified by `user_code`, preventing
331        the device from obtaining an access token. Once denied, the device will
332        receive an `access_denied` error on its next token poll.
333        Requires a valid user session. The `user_code` must belong to a pending
334        authorization associated with the calling app. Attempting to deny an already
335        approved, already denied, or expired authorization returns a 400.
336
337        Args:
338            input: Request body.
339            input.user_code: User-facing verification code shown on the device. Identifies the pending authorization to deny.
340
341        Returns:
342            Confirmation that the device authorization was denied. The `status` field will be `"denied"`.
343        """
344        return self._http.request(
345            "/oauth/device/deny",
346            method="POST",
347            body=input,
348            response_type=DeviceAuthorizationStatusResponse,
349        )

Deny a device authorization request Rejects the pending device authorization identified by user_code, preventing the device from obtaining an access token. Once denied, the device will receive an access_denied error on its next token poll. Requires a valid user session. The user_code must belong to a pending authorization associated with the calling app. Attempting to deny an already approved, already denied, or expired authorization returns a 400.

Arguments:
  • input: Request body.
  • input.user_code: User-facing verification code shown on the device. Identifies the pending authorization to deny.
Returns:

Confirmation that the device authorization was denied. The status field will be "denied".

class OauthResource:
352class OauthResource:
353    def __init__(self, http: SyncHttpClient):
354        self._http = http
355        self.device = DeviceResource(http)
356
357    def scopes(self) -> OauthScopesResponse:
358        """
359        List available OAuth scopes
360        Returns the complete set of OAuth scopes that the platform supports.
361        Use this endpoint to discover which scopes are available before constructing
362        an authorization request or rendering a consent UI.
363        No authentication is required. The response is the same for all callers.
364
365        Returns:
366            Successful response
367        """
368        return self._http.request("/oauth/scopes", response_type=OauthScopesResponse)
369
370    def token(self, input: OauthTokenInput) -> OAuthTokenResponse:
371        """
372        Exchange a grant for OAuth tokens
373        Issues an access token and a refresh token in exchange for a valid grant.
374        Three grant types are supported: `"authorization_code"`, `"refresh_token"`,
375        and `"urn:ietf:params:oauth:grant-type:device_code"`.
376        For `"authorization_code"` grants, supply `code`, `client`, `redirect_uri`, and
377        optionally `code_verifier` for PKCE flows. Each authorization code is single-use;
378        consuming it a second time returns `invalid_grant`.
379        For `"refresh_token"` grants, supply `refresh_token`. Resource-bound public
380        clients must also supply `client`. The endpoint rotates the refresh token on
381        every call and returns a fresh pair of tokens.
382        For device-code grants, supply `device_code` and `client`. Poll this endpoint
383        after receiving `authorization_pending` until the user approves or the code
384        expires. Slow down polling if you receive `slow_down`.
385        This endpoint is rate-limited to 20 requests per IP per 60 seconds. Exceeding
386        the limit returns HTTP 429 with `"error": "too_many_requests"`.
387
388        Args:
389            input: Request body.
390            input.client: OAuth client ID identifying the application requesting tokens. Required for `"authorization_code"`, device-code, and resource-bound refresh grants.
391            input.code: Single-use authorization code issued by the authorization endpoint. Required for `"authorization_code"` grants.
392            input.code_verifier: PKCE code verifier corresponding to the `code_challenge` sent in the authorization request. Required when the authorization code was issued with a code challenge; omit otherwise.
393            input.device_code: Device code received from the device authorization endpoint. Required for device-code grants.
394            input.grant_type: The OAuth 2.0 grant type. One of `"authorization_code"`, `"refresh_token"`, or `"urn:ietf:params:oauth:grant-type:device_code"`.
395            input.redirect_uri: Redirect URI that was used in the original authorization request. Must exactly match the URI on record for the client. Required for `"authorization_code"` grants.
396            input.refresh_token: Refresh token received from a previous token response. Required for `"refresh_token"` grants. The token is rotated on each successful call.
397            input.resource: Resource audience. Required for code exchange and refresh of a token bound to a resource server; must match the consent grant.
398
399        Returns:
400            Token pair issued for the authenticated user.
401        """
402        return self._http.request(
403            "/oauth/token",
404            method="POST",
405            body=input,
406            response_type=OAuthTokenResponse,
407        )
353    def __init__(self, http: SyncHttpClient):
354        self._http = http
355        self.device = DeviceResource(http)
device
def scopes(self) -> OauthScopesResponse:
357    def scopes(self) -> OauthScopesResponse:
358        """
359        List available OAuth scopes
360        Returns the complete set of OAuth scopes that the platform supports.
361        Use this endpoint to discover which scopes are available before constructing
362        an authorization request or rendering a consent UI.
363        No authentication is required. The response is the same for all callers.
364
365        Returns:
366            Successful response
367        """
368        return self._http.request("/oauth/scopes", response_type=OauthScopesResponse)

List available OAuth scopes Returns the complete set of OAuth scopes that the platform supports. Use this endpoint to discover which scopes are available before constructing an authorization request or rendering a consent UI. No authentication is required. The response is the same for all callers.

Returns:

Successful response

def token( self, input: OauthTokenInput) -> archastro.platform.types.oauth.OAuthTokenResponse:
370    def token(self, input: OauthTokenInput) -> OAuthTokenResponse:
371        """
372        Exchange a grant for OAuth tokens
373        Issues an access token and a refresh token in exchange for a valid grant.
374        Three grant types are supported: `"authorization_code"`, `"refresh_token"`,
375        and `"urn:ietf:params:oauth:grant-type:device_code"`.
376        For `"authorization_code"` grants, supply `code`, `client`, `redirect_uri`, and
377        optionally `code_verifier` for PKCE flows. Each authorization code is single-use;
378        consuming it a second time returns `invalid_grant`.
379        For `"refresh_token"` grants, supply `refresh_token`. Resource-bound public
380        clients must also supply `client`. The endpoint rotates the refresh token on
381        every call and returns a fresh pair of tokens.
382        For device-code grants, supply `device_code` and `client`. Poll this endpoint
383        after receiving `authorization_pending` until the user approves or the code
384        expires. Slow down polling if you receive `slow_down`.
385        This endpoint is rate-limited to 20 requests per IP per 60 seconds. Exceeding
386        the limit returns HTTP 429 with `"error": "too_many_requests"`.
387
388        Args:
389            input: Request body.
390            input.client: OAuth client ID identifying the application requesting tokens. Required for `"authorization_code"`, device-code, and resource-bound refresh grants.
391            input.code: Single-use authorization code issued by the authorization endpoint. Required for `"authorization_code"` grants.
392            input.code_verifier: PKCE code verifier corresponding to the `code_challenge` sent in the authorization request. Required when the authorization code was issued with a code challenge; omit otherwise.
393            input.device_code: Device code received from the device authorization endpoint. Required for device-code grants.
394            input.grant_type: The OAuth 2.0 grant type. One of `"authorization_code"`, `"refresh_token"`, or `"urn:ietf:params:oauth:grant-type:device_code"`.
395            input.redirect_uri: Redirect URI that was used in the original authorization request. Must exactly match the URI on record for the client. Required for `"authorization_code"` grants.
396            input.refresh_token: Refresh token received from a previous token response. Required for `"refresh_token"` grants. The token is rotated on each successful call.
397            input.resource: Resource audience. Required for code exchange and refresh of a token bound to a resource server; must match the consent grant.
398
399        Returns:
400            Token pair issued for the authenticated user.
401        """
402        return self._http.request(
403            "/oauth/token",
404            method="POST",
405            body=input,
406            response_type=OAuthTokenResponse,
407        )

Exchange a grant for OAuth tokens Issues an access token and a refresh token in exchange for a valid grant. Three grant types are supported: "authorization_code", "refresh_token", and "urn:ietf:params:oauth:grant-type:device_code". For "authorization_code" grants, supply code, client, redirect_uri, and optionally code_verifier for PKCE flows. Each authorization code is single-use; consuming it a second time returns invalid_grant. For "refresh_token" grants, supply refresh_token. Resource-bound public clients must also supply client. The endpoint rotates the refresh token on every call and returns a fresh pair of tokens. For device-code grants, supply device_code and client. Poll this endpoint after receiving authorization_pending until the user approves or the code expires. Slow down polling if you receive slow_down. This endpoint is rate-limited to 20 requests per IP per 60 seconds. Exceeding the limit returns HTTP 429 with "error": "too_many_requests".

Arguments:
  • input: Request body.
  • input.client: OAuth client ID identifying the application requesting tokens. Required for "authorization_code", device-code, and resource-bound refresh grants.
  • input.code: Single-use authorization code issued by the authorization endpoint. Required for "authorization_code" grants.
  • input.code_verifier: PKCE code verifier corresponding to the code_challenge sent in the authorization request. Required when the authorization code was issued with a code challenge; omit otherwise.
  • input.device_code: Device code received from the device authorization endpoint. Required for device-code grants.
  • input.grant_type: The OAuth 2.0 grant type. One of "authorization_code", "refresh_token", or "urn:ietf:params:oauth:grant-type:device_code".
  • input.redirect_uri: Redirect URI that was used in the original authorization request. Must exactly match the URI on record for the client. Required for "authorization_code" grants.
  • input.refresh_token: Refresh token received from a previous token response. Required for "refresh_token" grants. The token is rotated on each successful call.
  • input.resource: Resource audience. Required for code exchange and refresh of a token bound to a resource server; must match the consent grant.
Returns:

Token pair issued for the authenticated user.