DeviceAuthAPI
Device authorization lets a secondary client obtain access after the user approves a short user code in the browser or another logged-in session.
IDE / plugin flow
| Method | Description |
|---|---|
MainApiV1StartDeviceAuthInitPost | Start device authorization |
MainApiV1StartDeviceAuthAuthorizePost | Authorize with user code |
MainApiV1StartDeviceAuthPollGet | Poll authorization status |
deviceSession, _, err := client.DeviceAuthAPI.
MainApiV1StartDeviceAuthInitPost(context.Background()).
Execute()
authorizationBody := analogwakatime.NewMainApiV1StartDeviceAuthDesktopAgentAuthorizePostRequest(
"USER_CODE",
)
authorizedDevice, _, err := client.DeviceAuthAPI.
MainApiV1StartDeviceAuthAuthorizePost(ctx).
MainApiV1StartDeviceAuthDesktopAgentAuthorizePostRequest(*authorizationBody).
Execute()
deviceResult, _, err := client.DeviceAuthAPI.
MainApiV1StartDeviceAuthPollGet(context.Background()).
DeviceCode("DEVICE_CODE").
Execute()
Desktop-agent flow
initBody := analogwakatime.NewMainApiV1StartDeviceAuthDesktopAgentInitPostRequest()
agentSession, _, err := client.DeviceAuthAPI.
MainApiV1StartDeviceAuthDesktopAgentInitPost(context.Background()).
MainApiV1StartDeviceAuthDesktopAgentInitPostRequest(*initBody).
Execute()
authorizeBody := analogwakatime.NewMainApiV1StartDeviceAuthDesktopAgentAuthorizePostRequest(
"USER_CODE",
)
authorizedAgent, _, err := client.DeviceAuthAPI.
MainApiV1StartDeviceAuthDesktopAgentAuthorizePost(ctx).
MainApiV1StartDeviceAuthDesktopAgentAuthorizePostRequest(*authorizeBody).
Execute()
agentResult, _, err := client.DeviceAuthAPI.
MainApiV1StartDeviceAuthDesktopAgentPollGet(context.Background()).
DeviceCode("DEVICE_CODE").
Execute()
Android flow
androidSession, _, err := client.DeviceAuthAPI.
InitAndroidDeviceAuth(context.Background()).
Execute()
androidBody := analogwakatime.NewAuthorizeAndroidDeviceRequest("USER_CODE")
authorizedAndroid, _, err := client.DeviceAuthAPI.
AuthorizeAndroidDevice(ctx).
AuthorizeAndroidDeviceRequest(*androidBody).
Execute()
androidResult, _, err := client.DeviceAuthAPI.
PollAndroidDeviceAuth(context.Background()).
DeviceCode("DEVICE_CODE").
Execute()
Init and poll typically run without a user token. Authorize runs with an authenticated context.