{"record":{"id":"19f8f5cf218981e0","repo":"Budibase/budibase","slug":"oauth2-access-token-could-not-be-refreshed-erro","errorCode":null,"errorMessage":"OAuth2 access token could not be refreshed: ${errorMessage}","messagePattern":"OAuth2 access token could not be refreshed: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/server/src/threads/query.ts","lineNumber":374,"sourceCode":"      configId\n    )\n\n    // Refresh session flow. Should be in same location as refreshOAuthToken\n    // There are several other properties available in 'resp'\n    if (!resp.err) {\n      const globalUserId = getGlobalIDFromUserMetadataID(_id)\n      await auth.updateUserOAuth(globalUserId, resp)\n      if (!this.ctx) {\n        this.ctx = {}\n      }\n      this.ctx.user = (await cache.user.getUser({\n        userId: globalUserId,\n      })) as SSOUser\n    } else {\n      // In this event the user may have oAuth issues that\n      // could require re-authenticating with their provider.\n      let errorMessage = resp.err.data ? resp.err.data : resp.err.toString()\n      throw new Error(\n        \"OAuth2 access token could not be refreshed: \" + errorMessage\n      )\n    }\n\n    return resp\n  }\n\n  async getDynamicVariable(variable: QueryVariable) {\n    let { parameters } = this\n    const queryId = variable.queryId,\n      name = variable.name\n    let value = await threadUtils.getCachedVariable(queryId, name)\n    if (!value) {\n      value = this.queryResponse[queryId]\n        ? this.queryResponse[queryId]\n        : await this.runAnotherQuery(queryId, parameters)\n      // store incase this query is to be called again\n      this.queryResponse[queryId] = value","sourceCodeStart":356,"sourceCodeEnd":392,"githubUrl":"https://github.com/Budibase/budibase/blob/a81a902e9a8fe55b467d106765f6638f12e35c49/packages/server/src/threads/query.ts#L356-L392","documentation":"Error \"OAuth2 access token could not be refreshed: ${errorMessage}\" thrown in Budibase/budibase.","triggerScenarios":"Thrown at packages/server/src/threads/query.ts:374 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"a81a902e9a8fe55b467d106765f6638f12e35c49","analyzedAt":"2026-08-29T01:03:10.972Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}