providers/nextcloud
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/nextcloudorhttp://localhost:3000/api/auth/callback/nextcloudfor development.
- For the redirection URL, use
- 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β
- Nextcloud Documentation
- Nextcloud OAuth 2
- Nextcloud Clients and Client APIs
- Nextcloud User provisioning API
Notesβ
By default, Auth.js assumes that the Nextcloud provider is based on the OAuth 2 specification.
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!
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.
The Nextcloud provider comes with a default configuration. To override the defaults for your use case, check out customizing a built-in OAuth provider.
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β
| Parameter | Type |
|---|---|
options | OAuthUserConfig<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";