@@ -1184,70 +1184,7 @@ export const auth = betterAuth({
11841184 'delete:issue-worklog:jira' ,
11851185 'write:issue-link:jira' ,
11861186 'delete:issue-link:jira' ,
1187- ] ,
1188- responseType : 'code' ,
1189- pkce : true ,
1190- accessType : 'offline' ,
1191- authentication : 'basic' ,
1192- prompt : 'consent' ,
1193- redirectURI : `${ getBaseUrl ( ) } /api/auth/oauth2/callback/jira` ,
1194- getUserInfo : async ( tokens ) => {
1195- try {
1196- const response = await fetch ( 'https://api.atlassian.com/me' , {
1197- headers : {
1198- Authorization : `Bearer ${ tokens . accessToken } ` ,
1199- } ,
1200- } )
1201-
1202- if ( ! response . ok ) {
1203- logger . error ( 'Error fetching Jira user info:' , {
1204- status : response . status ,
1205- statusText : response . statusText ,
1206- } )
1207- return null
1208- }
1209-
1210- const profile = await response . json ( )
1211-
1212- const now = new Date ( )
1213-
1214- return {
1215- id : profile . account_id ,
1216- name : profile . name || profile . display_name || 'Jira User' ,
1217- email : profile . email || `${ profile . account_id } @atlassian.com` ,
1218- image : profile . picture || undefined ,
1219- emailVerified : true ,
1220- createdAt : now ,
1221- updatedAt : now ,
1222- }
1223- } catch ( error ) {
1224- logger . error ( 'Error in Jira getUserInfo:' , { error } )
1225- return null
1226- }
1227- } ,
1228- } ,
1229-
1230- // Jira Service Management provider
1231- {
1232- providerId : 'jira-service-management' ,
1233- clientId : env . JIRA_CLIENT_ID as string ,
1234- clientSecret : env . JIRA_CLIENT_SECRET as string ,
1235- authorizationUrl : 'https://auth.atlassian.com/authorize' ,
1236- tokenUrl : 'https://auth.atlassian.com/oauth/token' ,
1237- userInfoUrl : 'https://api.atlassian.com/me' ,
1238- scopes : [
1239- 'read:jira-user' ,
1240- 'read:jira-work' ,
1241- 'write:jira-work' ,
1242- 'read:project:jira' ,
1243- 'read:me' ,
1244- 'offline_access' ,
1245- 'read:issue:jira' ,
1246- 'read:status:jira' ,
1247- 'read:user:jira' ,
1248- 'read:issue-details:jira' ,
1249- 'write:comment:jira' ,
1250- 'read:comment:jira' ,
1187+ // Jira Service Management scopes
12511188 'read:servicedesk:jira-service-management' ,
12521189 'read:requesttype:jira-service-management' ,
12531190 'read:request:jira-service-management' ,
@@ -1282,7 +1219,7 @@ export const auth = betterAuth({
12821219 accessType : 'offline' ,
12831220 authentication : 'basic' ,
12841221 prompt : 'consent' ,
1285- redirectURI : `${ getBaseUrl ( ) } /api/auth/oauth2/callback/jira-service-management ` ,
1222+ redirectURI : `${ getBaseUrl ( ) } /api/auth/oauth2/callback/jira` ,
12861223 getUserInfo : async ( tokens ) => {
12871224 try {
12881225 const response = await fetch ( 'https://api.atlassian.com/me' , {
@@ -1292,7 +1229,7 @@ export const auth = betterAuth({
12921229 } )
12931230
12941231 if ( ! response . ok ) {
1295- logger . error ( 'Error fetching Jira Service Management user info:' , {
1232+ logger . error ( 'Error fetching Jira user info:' , {
12961233 status : response . status ,
12971234 statusText : response . statusText ,
12981235 } )
@@ -1305,15 +1242,15 @@ export const auth = betterAuth({
13051242
13061243 return {
13071244 id : profile . account_id ,
1308- name : profile . name || profile . display_name || 'JSM User' ,
1245+ name : profile . name || profile . display_name || 'Jira User' ,
13091246 email : profile . email || `${ profile . account_id } @atlassian.com` ,
13101247 image : profile . picture || undefined ,
13111248 emailVerified : true ,
13121249 createdAt : now ,
13131250 updatedAt : now ,
13141251 }
13151252 } catch ( error ) {
1316- logger . error ( 'Error in Jira Service Management getUserInfo:' , { error } )
1253+ logger . error ( 'Error in Jira getUserInfo:' , { error } )
13171254 return null
13181255 }
13191256 } ,
0 commit comments