Error: Error refreshing access token: Request failed with status code 400

Hello everyone, I need your help. After setting up the worker, the accounts are not synced. Looking up the worker logs it shows: worker-1 | [Nest] 73 - 05/17/2024, 8:26:39 AM ERROR [GmailFullSyncJob] Error refreshing access token for connected account XXXXX in workspace XXXX Error: Error refreshing access token: Request failed with status code 400 This is my .env TAG=latest PG_DATABASE_HOST=db:5432 NGINX_PUBLIC_PORT=80 NGINX_PUBLIC_SSL_PORT=443 SERVER_URL={server_url} SIGN_IN_PREFILLED=true STORAGE_TYPE=local STORAGE_LOCAL_PATH=../../.local-storage ACCESS_TOKEN_SECRET=xxxx LOGIN_TOKEN_SECRET=xxxx REFRESH_TOKEN_SECRET=xxxx FILE_TOKEN_SECRET=xxxx POSTGRES_ADMIN_PASSWORD=xxxx MESSAGING_PROVIDER_GMAIL_ENABLED=true AUTH_GOOGLE_ENABLED=true MESSAGING_PROVIDER_GMAIL_ENABLED=true CALENDAR_PROVIDER_GOOGLE_ENABLED=true AUTH_GOOGLE_CLIENT_ID=xxxx AUTH_GOOGLE_CLIENT_SECRET=xxxx AUTH_GOOGLE_CALLBACK_URL={server_url}auth/google/redirect AUTH_GOOGLE_APIS_CALLBACK_URL={server_url}/auth/google-apis/get-access-token Can you please help?
4 Replies
michele.laurelli
michele.laurelliβ€’6mo ago
@Weiko Can you give me a hand here? Thank you! πŸ™‚
Weiko
Weikoβ€’6mo ago
Hi @michele.laurelli, this query is made before each sync. In theory, we don't need to refresh the token that often but since GMAIL api says the expiration can be inconsistent, that's how we resolve that. Now to your problem it seems the request made to google is incorrect. The request is there GoogleAPIRefreshAccessTokenService#refreshAccessToken, do you have a refreshToken when you check in the DB? (connectedAccount table)
Emulator
Emulatorβ€’6mo ago
hi @Weiko, thank you for your answer! Yes, we have the refreshToken as you can see here: I think is this Google API call that fails: token: maybe some permission of other kind of configuration in the Google Cloud Console is missing perhaps? For the sake of curiosity I also made a manual cURL request to Google APIs and works as expected: I fixed the issue, for the worker I was missing environment credentials, unfortunately is a silent issue so we should raise an exception when these credentials are not properly set for the worker πŸ™‚
charles
charlesβ€’5mo ago
+1, we are working on improving the robustness of the messaging sync feature. It should be better in 0.12 πŸ™‚
Want results from more Discord servers?
Add your server