{"record":{"id":"cf988b1a43a214f5","repo":"theonedev/onedev","slug":"account-name-needs-to-be-specified-to-generate-ref","errorCode":null,"errorMessage":"Account name needs to be specified to generate refresh token","messagePattern":"Account name needs to be specified to generate refresh token","errorType":"exception","errorClass":"ExplicitException","httpStatus":null,"severity":"error","filePath":"server-plugin/server-plugin-mail-gmail/src/main/java/io/onedev/server/plugin/mail/gmail/GmailConnector.java","lineNumber":134,"sourceCode":"\t\treturn inboxPollSetting;\n\t}\n\n\tpublic void setInboxPollSetting(InboxPollSetting inboxPollSetting) {\n\t\tthis.inboxPollSetting = inboxPollSetting;\n\t}\n\n\t@SuppressWarnings(\"unused\")\n\tprivate static RefreshToken.Callback getRefreshTokenCallback() {\n\t\tString clientId = (String) EditContext.get().getInputValue(\"clientId\");\n\t\tif (clientId == null)\n\t\t\tthrow new ExplicitException(\"Client ID needs to be specified to generate refresh token\");\n\t\tString clientSecret = (String) EditContext.get().getInputValue(\"clientSecret\");\n\t\tif (clientSecret == null)\n\t\t\tthrow new ExplicitException(\"Client secret needs to be specified to generate refresh token\");\n\n\t\tString accountName = (String) EditContext.get().getInputValue(\"accountName\");\n\t\tif (accountName == null)\n\t\t\tthrow new ExplicitException(\"Account name needs to be specified to generate refresh token\");\n\n\t\tCollection<String> scopes = Lists.newArrayList(\"https://mail.google.com/\");\n\n\t\treturn new RefreshToken.Callback() {\n\n\t\t\t@Override\n\t\t\tpublic String getAuthorizeEndpoint() {\n\t\t\t\treturn AUTHORIZE_ENDPOINT;\n\t\t\t}\n\n\t\t\t@Override\n\t\t\tpublic Map<String, String> getAuthorizeParams() {\n\t\t\t\tMap<String, String> params = new HashMap<>();\n\t\t\t\tparams.put(\"access_type\", \"offline\");\n\t\t\t\tparams.put(\"login_hint\", accountName);\n\t\t\t\tparams.put(\"prompt\", \"consent\");\n\t\t\t\treturn params;\n\t\t\t}","sourceCodeStart":116,"sourceCodeEnd":152,"githubUrl":"https://github.com/theonedev/onedev/blob/d44925c47c37992c828ea673a5f9620539bc3ff2/server-plugin/server-plugin-mail-gmail/src/main/java/io/onedev/server/plugin/mail/gmail/GmailConnector.java#L116-L152","documentation":"GmailConnector's refresh-token callback additionally requires the Gmail account name (email address) being configured. Without it the resulting refresh token cannot be tied to the right account, so an ExplicitException is thrown.","triggerScenarios":"Generating a refresh token with clientId and clientSecret filled but the 'Account Name' input empty in the Gmail connector edit form.","commonSituations":"User fills OAuth credentials but forgets the mailbox address field; using a service account vs user mailbox confusion; field left blank on a cloned connector config.","solutions":["Fill in the Gmail account name (full email address of the mailbox to send from) before generating the refresh token.","Ensure the entered account matches the one you authorize in the Google consent screen.","Re-open the connector form and complete all required fields (clientId, clientSecret, accountName)."],"exampleFix":"// before\naccountName = null;\n// after\naccountName = \"notifications@example.com\";","handlingStrategy":"validation","validationCode":"if (!accountName || accountName.trim() === \"\") throw new Error(\"Fill Account Name before generating refresh token\");","typeGuard":null,"tryCatchPattern":"try {\n    generateRefreshToken();\n} catch (ExplicitException e) {\n    alert(\"Complete the connector form first: \" + e.getMessage());\n}","preventionTips":["Enter the full Gmail address of the sending mailbox.","Ensure the authorized Google account matches the account name field.","Use a checklist: clientId, clientSecret, accountName before generating."],"tags":["gmail","oauth","validation"],"backgroundTag":"missing-required-config-field","analyzedSha":"d44925c47c37992c828ea673a5f9620539bc3ff2","analyzedAt":"2026-09-06T07:18:27.995Z","contentChangedAt":"2026-09-06T07:18:27.995Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}