Next.js Discord

Discord Forum

Struggling to setup Atlassian w/ next-auth

Unanswered
Song Sparrow posted this in #help-forum
Open in Discord
Avatar
Song SparrowOP
Hey all, I'm struggling to work with/setup an Atlassian login w/ my NextJS 13 app. I keep getting the page in the attached screenshot instead of the expected sign-in screen.

Here's my code:
import NextAuth, { type DefaultSession } from 'next-auth';
import Atlassian from "next-auth/providers/atlassian";

declare module 'next-auth' {
  interface Session {
    user: {
      /** The user's id. */
      id: string;
    } & DefaultSession['user'];
  }
}

export const {
  handlers: { GET, POST },
  auth,
} = NextAuth({
  providers: [
    Atlassian({
      clientId: process.env.ATLASSIAN_CLIENT_ID,
      clientSecret: process.env.ATLASSIAN_CLIENT_SECRET,
      authorization: {
        params: {
          scope: "read:me read:account read:confluence-space.summary read:confluence-props read:confluence-content.all read:confluence-content.summary search:confluence read:confluence-content.permission read:confluence-user read:confluence-groups readonly:content.attachment:confluence read:jira-work read:jira-user"
        }
      }
    }),
  ],
  callbacks: {
    jwt: async ({ token, profile }) => {
      if (profile) {
        token.id = profile.id;
        token.image = profile.picture;
      }
      return token;
    },
    signIn: async ({account, profile}) => {
      // TODO: this is where we will validate w/ backend database of users
      console.log('sign in ran', account, profile);
      return true
    }
  },
  pages: {
    signIn: '/sign-in',
  },
});


Other notes:
- I've added my callback url here: https://developer.atlassian.com/console/myapps/MY_APP_ID/authorization/auth-code-grant
- I got the client id and secret from here: https://developer.atlassian.com/console/myapps/MY_APP_ID/settings
- My distribution status is set to "Sharing"
- I've added the relevant scopes (i.e. scopes in the above code) to https://developer.atlassian.com/console/myapps/MY_APP_ID/permissions (but I don't think this should make a difference)
Image

0 Replies