Docs

Examples

NextAuth

To configure NextAuth with Hydda IdP, you need to use the default oauth provider. All values, except secrets, are provided by the openid-configuration endpoint.
The secrets are provided by your Hydda contact, or by logging in to the Hydda Console and retrieving them from the Applications page.

Code

const hyddaIdpUrl = 'https://idp.dev.hydda.cloud'
const issuer = 'https://cognito-idp.eu-north-1.amazonaws.com/eu-north-1_afO8g66RA'; // This is provided by the openid-configuration endpoint
const nextAuthOptions: AuthOptions = {
  ...
  ,
  providers: [
    {
      id: 'hydda-idp',
      name: 'Hydda IdP',
      clientId: '<your-client-id>',
      type: 'oauth',
      idToken: true,
      authorization: {
        url: `${hyddaIdpUrl}/oauth2/authorize`,
        params: {
          client_id: '<your-client-id>',
          response_type: 'code',
        },
      },
      issuer: issuer,
      jwks_endpoint: `${hyddaIdpUrl}/.well-known/jwks.json`,
      checks: ['pkce', 'state'],
      clientSecret: '<your-client-secret>',
      userinfo: `${hyddaIdpUrl}/oauth2/userinfo`,
      token: {
        url: `${hyddaIdpUrl}/oauth2/token`,
      },
      profile(profile) {
        return {
          id: profile.sub,
          ...profile,
        }
      },
    },
  ],
}