MCPcopy Create free account
hub / github.com/dailydotdev/apps / oauthRequest

Function oauthRequest

packages/shared/src/lib/oauthApps.ts:59–82  ·  view source on GitHub ↗
(
  path: string,
  body?: Record<string, unknown>,
)

Source from the content-addressed store, hash-verified

57}
58
59const oauthRequest = async <T>(
60 path: string,
61 body?: Record<string, unknown>,
62): Promise<T> => {
63 const res = await fetch(`${apiUrl}/auth/oauth2/${path}`, {
64 method: body ? 'POST' : 'GET',
65 credentials: 'include',
66 headers: {
67 Accept: 'application/json',
68 ...(body && { 'Content-Type': 'application/json' }),
69 },
70 ...(body && { body: JSON.stringify(body) }),
71 });
72 const data = await res.json().catch(() => null);
73
74 if (!res.ok) {
75 throw new OAuthRequestError(
76 getBetterAuthErrorMessage(data?.error_description ?? data),
77 res.status,
78 );
79 }
80
81 return data as T;
82};
83
84export const getOAuthClients = (): Promise<OAuthClient[]> =>
85 oauthRequest<OAuthClient[]>('get-clients');

Callers 8

getOAuthClientsFunction · 0.85
createOAuthClientFunction · 0.85
updateOAuthClientFunction · 0.85
rotateOAuthClientSecretFunction · 0.85
deleteOAuthClientFunction · 0.85
getOAuthConsentsFunction · 0.85
getOAuthPublicClientFunction · 0.85
deleteOAuthConsentFunction · 0.85

Calls 1

Tested by

no test coverage detected