MCPcopy Create free account
hub / github.com/davialabs/davia / requestDeviceCode

Function requestDeviceCode

apps/cli/src/sync.ts:149–167  ·  view source on GitHub ↗

* Requests a device code from the OAuth server

()

Source from the content-addressed store, hash-verified

147 * Requests a device code from the OAuth server
148 */
149async function requestDeviceCode(): Promise<DeviceCodeResponse> {
150 const serverUrl = getServerUrl();
151 const response = await fetch(`${serverUrl}/oauth/device/code`, {
152 method: "POST",
153 headers: {
154 "Content-Type": "application/json",
155 },
156 body: JSON.stringify({} as DeviceCodeRequest),
157 });
158
159 if (!response.ok) {
160 const errorText = await response.text();
161 throw new Error(
162 `Failed to request device code: ${response.status} ${errorText}`
163 );
164 }
165
166 return (await response.json()) as DeviceCodeResponse;
167}
168
169/**
170 * Polls for an access token using the device code

Callers 1

ensureLoggedInFunction · 0.85

Calls 1

getServerUrlFunction · 0.85

Tested by

no test coverage detected