({ state }: { state: string })
| 156 | ); |
| 157 | |
| 158 | export const getGoogleDriveAuthUrl = ({ state }: { state: string }) => { |
| 159 | const env = serverEnv(); |
| 160 | if (!env.GOOGLE_CLIENT_ID) { |
| 161 | throw new Error("GOOGLE_CLIENT_ID is not configured"); |
| 162 | } |
| 163 | |
| 164 | const params = new URLSearchParams({ |
| 165 | client_id: env.GOOGLE_CLIENT_ID, |
| 166 | redirect_uri: `${env.WEB_URL}/api/desktop/storage/google-drive/callback`, |
| 167 | response_type: "code", |
| 168 | access_type: "offline", |
| 169 | prompt: "consent", |
| 170 | scope: DRIVE_FILE_SCOPE, |
| 171 | state, |
| 172 | include_granted_scopes: "true", |
| 173 | }); |
| 174 | |
| 175 | return `https://accounts.google.com/o/oauth2/v2/auth?${params.toString()}`; |
| 176 | }; |
| 177 | |
| 178 | export const exchangeGoogleDriveCode = (code: string) => |
| 179 | Effect.tryPromise({ |
no test coverage detected