Skip to main content

providers/nextcloud

Built-in Nextcloud integration.

default()​

Add Nextcloud login to your page.

Setup​

Callback URL​

https://example.com/api/auth/callback/nextcloud

Configuration​

import { Auth } from "@auth/core";
import Nextcloud from "@auth/core/providers/nextcloud";

const request = new Request(origin);
const response = await Auth(request, {
providers: [
Nextcloud({
clientId: process.env.NEXTCLOUD_CLIENT_ID,
clientSecret: process.env.NEXTCLOUD_CLIENT_SECRET,
issuer: process.env.NEXTCLOUD_ISSUER,
}),
],
});

Configuring Nextcloud​

Follow these steps:

  • Login to your Nextcloud instance as an administrator.
  • Head over to your Administrator Security Settings.
    • Click on your profile picture in the top right corner and select Administration settings from the dropdown menu.
    • On left sidebar, scroll down and click on Security.
  • Under OAuth 2.0 clients, enter the name of your application and provide a redirection URL.
    • For the redirection URL, use https://yourapplication.com/api/auth/callback/nextcloud or http://localhost:3000/api/auth/callback/nextcloud for development.
  • Click on Add. You should now have a Client Identifier and Secret.

In .env.local create the following entries:

NEXTCLOUD_CLIENT_ID="Your client identifier"
NEXTCLOUD_CLIENT_SECRET="Your client secret"
NEXTCLOUD_ISSUER=https://your-nextcloud-instance.com

Resources​

Notes​

By default, Auth.js assumes that the Nextcloud provider is based on the OAuth 2 specification.

danger

Nextcloud OAuth 2 implementation currently does not support scoped access. This means that every token has full access to the complete account including read and write permission to the stored files. It is essential to store the OAuth 2 tokens in a safe way!

tip

Some Nextcloud API endpoints return XML instead of JSON. To make the API return JSON, add the Accept: application/json header to the request. Some endpoints also require the OCS-APIRequest: true header.

tip

The Nextcloud provider comes with a default configuration. To override the defaults for your use case, check out customizing a built-in OAuth provider.

Disclaimer

If you think you found a bug in the default configuration, you can open an 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.

default(options: OAuthUserConfig<NextcloudProfile>): OAuthConfig<NextcloudProfile>

Parameters​

ParameterType
optionsOAuthUserConfig<NextcloudProfile>

Returns​

OAuthConfig<NextcloudProfile>


NextcloudProfile​

Represents the Nextcloud user profile data returned from the /ocs/v1.php/cloud/users/.

See​

Check out the documentation for more details

Properties​

address​

address: string

The address of the user.

Example​
"Foobar 12, 12345 Town";

biography​

biography: string

The biography or detailed description of the user.

displayname​

displayname: string

The display name of the user.

Example​
"Frank K.";

email​

email: null | string

The email address associated with the user.

Example​
"frank@domain.tld";

enabled​

enabled: boolean

Indicates whether the user account is enabled or disabled.

Example​
true;

fediverse​

fediverse: string

The user's Fediverse handle.

groups​

groups: string[]

An array of group names that the user belongs to.

Example​
["admin", "group1", "group2"];

headline​

headline: string

The headline or brief description of the user.

id​

id: string

The user's username.

Example​
"frank";

language​

language: string

The language preference of the user.

Example​
"en";

locale​

locale: string

The locale or language locale of the user.

Example​
"en_US";

organisation​

organisation: string

The organization associated with the user.

phone​

phone: string

The phone number of the user.

role​

role: string

The role or position of the user.

storageLocation​

storageLocation: string

The storage location of the user's files.

Example​
"/path/to/nextcloud/data/frank";

twitter​

twitter: string

The user's Twitter handle.

Example​
"Nextcloud";

website​

website: string

The website URL of the user.

Example​
"https://nextcloud.com";