MCPcopy Create free account
hub / github.com/gitify-app/gitify / startGitHubDeviceFlow

Function startGitHubDeviceFlow

src/renderer/utils/auth/flows.ts:94–116  ·  view source on GitHub ↗
(
  hostname: Hostname = Constants.GITHUB_HOSTNAME,
  scopes: string[] = getRecommendedScopeNames(),
)

Source from the content-addressed store, hash-verified

92 * @returns The device flow session data.
93 */
94export async function startGitHubDeviceFlow(
95 hostname: Hostname = Constants.GITHUB_HOSTNAME,
96 scopes: string[] = getRecommendedScopeNames(),
97): Promise<DeviceFlowSession> {
98 const deviceCode = await createDeviceCode({
99 clientType: 'oauth-app' as const,
100 clientId: Constants.OAUTH_DEVICE_FLOW_CLIENT_ID,
101 scopes: scopes,
102 request: request.defaults({
103 baseUrl: getGitHubAuthBaseUrl(hostname).toString(),
104 }),
105 });
106
107 return {
108 hostname: hostname,
109 clientId: Constants.OAUTH_DEVICE_FLOW_CLIENT_ID,
110 deviceCode: deviceCode.data.device_code,
111 userCode: deviceCode.data.user_code,
112 verificationUri: deviceCode.data.verification_uri,
113 intervalSeconds: deviceCode.data.interval,
114 expiresAt: Date.now() + deviceCode.data.expires_in * 1000,
115 } as DeviceFlowSession;
116}
117
118/**
119 * Poll GitHub to exchange a device code for an access token.

Callers 1

AppProviderFunction · 0.90

Calls 3

getRecommendedScopeNamesFunction · 0.90
getGitHubAuthBaseUrlFunction · 0.90
toStringMethod · 0.80

Tested by

no test coverage detected