MCPcopy
hub / github.com/remotely-save/remotely-save / setConfigBySuccessfullAuthInplace

Function setConfigBySuccessfullAuthInplace

src/fsDropbox.ts:324–350  ·  view source on GitHub ↗
(
  config: DropboxConfig,
  authRes: DropboxSuccessAuthRes,
  saveUpdatedConfigFunc: () => Promise<any> | undefined
)

Source from the content-addressed store, hash-verified

322};
323
324export const setConfigBySuccessfullAuthInplace = async (
325 config: DropboxConfig,
326 authRes: DropboxSuccessAuthRes,
327 saveUpdatedConfigFunc: () => Promise<any> | undefined
328) => {
329 console.info("start updating local info of Dropbox token");
330
331 config.accessToken = authRes.access_token;
332 config.accessTokenExpiresInSeconds = Number.parseInt(authRes.expires_in);
333 config.accessTokenExpiresAtTime =
334 Date.now() + Number.parseInt(authRes.expires_in) * 1000 - 10 * 1000;
335
336 // manually set it expired after 80 days;
337 config.credentialsShouldBeDeletedAtTime =
338 Date.now() + OAUTH2_FORCE_EXPIRE_MILLISECONDS;
339
340 if (authRes.refresh_token !== undefined) {
341 config.refreshToken = authRes.refresh_token;
342 config.accountID = authRes.account_id!;
343 }
344
345 if (saveUpdatedConfigFunc !== undefined) {
346 await saveUpdatedConfigFunc();
347 }
348
349 console.info("finish updating local info of Dropbox token");
350};
351
352////////////////////////////////////////////////////////////////////////////////
353// real exported interface

Callers 2

onOpenMethod · 0.90
_initMethod · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected