/integrations/oauth2-apps`
*
* :::warning
*
* The Mattermost provider requires the `issuer` option to be set. This is the base url of your Mattermost instance. e.g https://my-cool-server.cloud.mattermost.com
*
* :::
*
* :::tip
*
* The Mattermost provider comes with a [default configuration](https://github.com/nextauthjs/next-auth/blob/main/packages/core/src/providers/mattermost.ts).
* To override the defaults for your use case, check out [customizing a built-in OAuth provider](https://authjs.dev/guides/configuring-oauth-providers).
*
* :::
*
* :::info **Disclaimer**
*
* If you think you found a bug in the default configuration, you can [open an issue](https://authjs.dev/new/provider-issue).
*
* Auth.js strictly adheres to the specification and it cannot take responsibility for any deviation from
* the spec by the provider. You can open an issue, but if the problem is non-compliance with the spec,
* we might not pursue a resolution. You can ask for more help in [Discussions](https://authjs.dev/new/github-discussions).
*
* :::
*/
export default function Mattermost(
config: OAuthUserConfig
& { issuer: string }
): OAuthConfig
{
const { issuer, ...rest } = config
return {
id: "mattermost",
name: "Mattermost",
type: "oauth",
client: { token_endpoint_auth_method: "client_secret_post" },
token: `${issuer}/oauth/access_token`,
authorization: `${issuer}/oauth/authorize`,
userinfo: `${issuer}/api/v4/users/me`,
profile(profile) {
return {
id: profile.id,
name: profile.username ?? `${profile.first_name} ${profile.last_name}`,
email: profile.email,
image: null,
}
},
style: { bg: "#000", text: "#fff" },
options: rest,
}
}