Title: Tim&#039;s Nextcloud SSO OAuth2
Author: Tim Oxendale
Published: <strong>February 11, 2022</strong>
Last modified: September 15, 2026

---

Search plugins

![](https://ps.w.org/tims-nextcloud-sso-oauth2/assets/banner-772x250.jpg?rev=2676930)

![](https://ps.w.org/tims-nextcloud-sso-oauth2/assets/icon-256x256.jpg?rev=2676930)

# Tim’s Nextcloud SSO OAuth2

 By [Tim Oxendale](https://profiles.wordpress.org/timssolutions/)

[Download](https://downloads.wordpress.org/plugin/tims-nextcloud-sso-oauth2.2.0.3.zip)

 * [Details](https://en-au.wordpress.org/plugins/tims-nextcloud-sso-oauth2/#description)
 * [Reviews](https://en-au.wordpress.org/plugins/tims-nextcloud-sso-oauth2/#reviews)
 *  [Installation](https://en-au.wordpress.org/plugins/tims-nextcloud-sso-oauth2/#installation)
 * [Development](https://en-au.wordpress.org/plugins/tims-nextcloud-sso-oauth2/#developers)

 [Support](https://wordpress.org/support/plugin/tims-nextcloud-sso-oauth2/)

## Description

Just a simple OAuth2 plugin so you can login to your WordPress site from Nextcloud,
there is an option to add a login button on the WordPress login page and a shortcode
so you can generate your own button. You can set what Nextcloud user groups get 
mapped to what WordPress user role and what page the users get redirected to on 
successful login. If you’re using the External sites app in Nextcloud you can set
the URL as www.example.com/wp-login.php?nc-sso=redirect and it will auto redirect
the user to your Nextcloud install to login without them having to click the login
button.

The plugin has been tested with Nextcloud 20.0.14 to 34.0.4.

If you have any problems please reach out on the support forum or directly [here](https://www.timoxendale.co.uk/plugins/wordpress-nextcloud-sso-oauth2/#support).

Note this isn’t an official plugin from Nextcloud, it’s just from someone that uses
it with WordPress alot.

## Screenshots

[⌊Options Page⌉⌊Options Page⌉[

Options Page

[⌊Options Page Step 4 User Actions Register⌉⌊Options Page Step 4 User Actions Register⌉[

Options Page Step 4 User Actions Register

[⌊Options Page Step 4 User Actions Custom⌉⌊Options Page Step 4 User Actions Custom⌉[

Options Page Step 4 User Actions Custom

[⌊Login Page⌉⌊Login Page⌉[

Login Page

## Installation

Install Tim’s Nextcloud SSO OAuth2 either via the WordPress.org plugin directory,
or by uploading the files to your server.

Activate the plugin through the ‘Plugins’ menu in WordPress.

Once Active go to Settings -> Nextcloud OAuth2 in the WordPress admin area and follow
the setup instructions.

## FAQ

### How do I set the plugin up?

If you go to the settings page (Settings -> Nextcloud OAuth2) it gives you a simple
breakdown of what’s needed to setup the OAuth2 connection with your Nextcloud install.

 1. Login to your Nextcloud install
 2. Go to Settings -> Security
 3. Then under “OAuth 2.0 clients” add a new client
 4. Set the name to anything you like and the redirect URL to your site URL
 5. Then copy the Client Identifier and Secret keys in the form

### What’s my Nextcloud URL?

This is the URL that you have installed Nextcloud at e.g. https://cloud.example.
com/, if you have installed it in a subfolder, please include that e.g. https://
example.com/cloud/. If your Nextcloud URLs look like https://example.com/index.php/
apps/dashboard/ then please include the /index.php/ in the URL e.g. https://example.
com/index.php/.

### Where is the settings page?

It’s under Settings and called “Nextcloud OAuth2”

### Is there a shortcode to add a login button?

Yes, it’s [nextcloud_login class=”btn”]button text[/nextcloud_login] and there is
an option to enable a button on the WordPress login screen, or you can use the URL
www.example.com/wp-login.php?nc-sso=redirect

### Are there any filters available so I can make my own changes?

Yes, there is:

tims_nso_authorize_url which is the Nextcloud URL the user gets redirected to, and
is also the last hook before they go off to your install of Nextcloud, example:

    ```
    add_filter('tims_nso_nextcloud_login_button_url', 'custom_function_name_one');
    function custom_function_name_one($authorize_url){
        // custom code
        return $authorize_url;
    }
    ```

tims_nso_successful_login_redirect which is the URL the user goes to after successfully
coming back from Nextcloud, example:

    ```
    add_filter('tims_nso_successful_login_redirect', 'custom_function_name_two');
    function custom_function_name_two($redirect_url){
        // custom code
        return $redirect_url;
    }
    ```

tims_nso_nextcloud_login_button_url which is the URL the login button and shortcode
login button uses, example:

    ```
    add_filter('tims_nso_nextcloud_login_button_url', 'custom_function_name_three');
    function custom_function_name_three($url){
        // custom code
        return $url;
    }
    ```

tims_nso_nextcloud_user_matched which is the WordPress WP_User (Object) and the 
user data (Object) from Nextcloud for the successful matched user, example:

    ```
    add_filter('tims_nso_nextcloud_user_matched', 'custom_function_name_four', 10, 2);
    function custom_function_name_four($user,$nextcloud){
        // custom code
        return $user;
    }
    ```

### I’m getting a “Nextcloud server returned but with an invalid state for this session” error

Before you go off to Nextcloud the site needs to store a unique key to verify the
response when you come back, if this key is removed before you come back this is
when you see this message.

By default, the key is stored in the PHP session but if you’re having trouble you
can go into the plugin options and set the “Temp Key Storage Type” to use a Cookie
and this should solve the issue.

### I’m stuck on my Nextcloud install when I click “Grant access”, it doesn’t do anything?

If you check the JS console log and see a message like “Refused to send form data
to … because it violates the following Content Security Policy directive….” then
you need to edit your Nextcloud config file, usually located at nextcloud/config/
config.php and add the line: ‘overwriteprotocol’ => ‘https’,

### Is there a paid version?

Nope, just a simple free plugin to enable you to login to your site with Nextcloud.

### I need help

If you have any problems please reach out on the support forum or directly [here](https://www.timoxendale.co.uk/plugins/wordpress-nextcloud-sso-oauth2/#support).
I’ll try my best to help.

## Reviews

![](https://secure.gravatar.com/avatar/f86de0bb5ff89fd67fa5228cd1b6a727e859ef29ed6d845100e923346261cc20?
s=60&d=retro&r=g)

### 󠀁[Works like a charm!](https://wordpress.org/support/topic/works-like-a-charm-2299/)󠁿

 [DER SEMINAR](https://profiles.wordpress.org/derseminar/) February 6, 2024 1 reply

Intuitive design, works the first time you try it. Tim, can I spend you a coffee
or something as a thank you?

![](https://secure.gravatar.com/avatar/db6e93e3583cb7458d325cee34f31e42f343c8a12461ed0cd75e75651b92123f?
s=60&d=retro&r=g)

### 󠀁[Perfect](https://wordpress.org/support/topic/perfect-10057/)󠁿

 [luk100r](https://profiles.wordpress.org/luk100r/) September 27, 2023

Works like a charm

![](https://secure.gravatar.com/avatar/2b9076cb15602e845d03706213da9933ff0a72ecc3d4fb2dfd1840326a7fbd61?
s=60&d=retro&r=g)

### 󠀁[Great plugin and best suppport ever](https://wordpress.org/support/topic/great-plugin-and-best-suppport-ever/)󠁿

 [bengrau](https://profiles.wordpress.org/bengrau/) May 17, 2023

Awesome plugin that works really well, but the best thing about it is Tim's support.
He'll answer you immediately and help you until it works. Thanks Tim, you're great!

![](https://secure.gravatar.com/avatar/b793a325335a9cbe3a3ffd3baa3c7e46ae510692fdebee62625df91f3f3e76a2?
s=60&d=retro&r=g)

### 󠀁[Awesome plugin](https://wordpress.org/support/topic/awesome-plugin-6813/)󠁿

 [Andreas Schneider](https://profiles.wordpress.org/cryptomilk/) March 17, 2023

Simple to configure and esay to set up. Great work!

![](https://secure.gravatar.com/avatar/1ea879d94acfb55b66ee52d87c53b2c25c5f45b264d3e874ca06f68b081aae9d?
s=60&d=retro&r=g)

### 󠀁[love it](https://wordpress.org/support/topic/love-it-3750/)󠁿

 [wheez123](https://profiles.wordpress.org/wheez123/) April 11, 2022

I don't have much to say. It was super simplet to setup and works perfectly. Thanks
for providing this plugin for free!

![](https://secure.gravatar.com/avatar/dcad6118e8c879b7a8919bfd9bba27a45516e01c9090b49c54e3e0010e18f93d?
s=60&d=retro&r=g)

### 󠀁[Easy to use – Just what I needed! Great Support!](https://wordpress.org/support/topic/easy-to-use-just-what-i-needed-great-support/)󠁿

 [gnomeore](https://profiles.wordpress.org/gnomeore/) March 18, 2022

I have been trying to get my WordPress site linked to my NextCloud file server for
well over a year. I needed to have a small main site (WordPress) while storing all
of my 1000+ PDF document files on a large Cloud File Server (NextCloud). I also 
needed to maintain user access to our Cloud Server (for alternate access). I tried
many plugins, Third Party solutions (KeyCloak, Auth0, MiniOrange, Okla, etc). I 
managed to get Auth0 running but it had a problem with authenticating with a commonly
used version of a common web browser (not their fault – the browser had faulty code
in their implementation of the handshaking procedure). Left it all alone for several
month's until our old web site died – which is why I was trying to get a new one
working with our existing Cloud Server. Then this plugin showed up and it was so
simple to setup and run. I had an issue with the default wp-login returning an error.
So I setup fresh servers and still no joy. In desperation I contacted the Developer.
He solved the problem within a day! Great service and I am very grateful to him 
for both publishing this great plugin and for the incredible response to my problems.
Highly Recommended!

 [ Read all 8 reviews ](https://wordpress.org/support/plugin/tims-nextcloud-sso-oauth2/reviews/)

## Contributors & Developers

“Tim's Nextcloud SSO OAuth2” is open source software. The following people have 
contributed to this plugin.

Contributors

 *   [ Tim Oxendale ](https://profiles.wordpress.org/timssolutions/)

[Translate “Tim's Nextcloud SSO OAuth2” into your language.](https://translate.wordpress.org/projects/wp-plugins/tims-nextcloud-sso-oauth2)

### Interested in development?

[Browse the code](https://plugins.trac.wordpress.org/browser/tims-nextcloud-sso-oauth2/),
check out the [SVN repository](https://plugins.svn.wordpress.org/tims-nextcloud-sso-oauth2/),
or subscribe to the [development log](https://plugins.trac.wordpress.org/log/tims-nextcloud-sso-oauth2/)
by [RSS](https://plugins.trac.wordpress.org/log/tims-nextcloud-sso-oauth2/?limit=100&mode=stop_on_copy&format=rss).

## Changelog

#### 2.0.3

Release Date: 22nd May 2025

 * Improvements made to the Test Connection option in the settings
 * Updated compatibility with WordPress 6.8.1 and Nextcloud 31.0.4

#### 2.0.2

Release Date: 10th August 2023

 * Implemented a feature request: When matching Nextcloud user groups to WordPress
   roles If no role matches there is now an option to select a default role for 
   the user
 * Corrected spelling mistakes on the options page

#### 2.0.1

Release Date: 1st July 2022

 * Added some filter hooks

#### 2.0.0

Release Date: 27th June 2022

 * Revamped the options page to be more visually pleasing
 * Added the option to redirect the user back to where they were
 * The shortcode login button is now hidden if the user is already logged in
 * Debug log contains more information

#### 1.9

Release Date: 23rd May 2022

 * Organised the options page
 * Added a button to test the Nextcloud URL
 * Added some filter hooks

#### 1.8

Release Date: 19th May 2022

 * Added additional checks when entering the Nextcloud URL

#### 1.7

Release Date: 6th May 2022

 * Updated compatibility with WordPress 6.1 and Nextcloud 24.0.0
 * Added some more FAQs
 * Made an error message more descriptive

#### 1.6

Release Date: 18th March 2022

 * Made improvements to the way session data is stored when going between WordPress
   and Nextcloud

#### 1.5

Release Date: 17th March 2022

 * Built in an option to store unique keys that are needed to verify the response
   back from Nextcloud as a PHP session or Cookie.

#### 1.4

Release Date: 17th March 2022

 * Made improvements to the way session data is stored when going between WordPress
   and Nextcloud
 * Tested compatibility with WordPress 5.9.3

#### 1.3

Release Date: 25th February 2022

 * Updated to be compatible with older Nextcloud installs
 * Logs more useful information to debug file when enabled

#### 1.2

Release Date: 25th February 2022

 * Fixed issues with URLs that include /index.php/

#### 1.1

Release Date: 25th February 2022

 * Added a new option to log debug information to a file

#### 1.0

Release Date: 11th February 2022

 * Initial release.

## Meta

 *  Version **2.0.3**
 *  Last updated **4 weeks ago**
 *  Active installations **200+**
 *  WordPress Version ** 4.0.0 or higher **
 *  Tested up to **7.1.3**
 *  PHP Version ** 8.0 or higher **
 *  Language
 * [English (US)](https://wordpress.org/plugins/tims-nextcloud-sso-oauth2/)
 * Tags
 * [login](https://en-au.wordpress.org/plugins/tags/login/)[Nextcloud](https://en-au.wordpress.org/plugins/tags/nextcloud/)
   [OAuth 2.0](https://en-au.wordpress.org/plugins/tags/oauth-2-0/)[Single Sign-on](https://en-au.wordpress.org/plugins/tags/single-sign-on/)
   [WordPress SSO](https://en-au.wordpress.org/plugins/tags/wordpress-sso/)
 *  [Advanced View](https://en-au.wordpress.org/plugins/tims-nextcloud-sso-oauth2/advanced/)

## Ratings

 5 out of 5 stars.

 *  [  8 5-star reviews     ](https://wordpress.org/support/plugin/tims-nextcloud-sso-oauth2/reviews/?filter=5)
 *  [  0 4-star reviews     ](https://wordpress.org/support/plugin/tims-nextcloud-sso-oauth2/reviews/?filter=4)
 *  [  0 3-star reviews     ](https://wordpress.org/support/plugin/tims-nextcloud-sso-oauth2/reviews/?filter=3)
 *  [  0 2-star reviews     ](https://wordpress.org/support/plugin/tims-nextcloud-sso-oauth2/reviews/?filter=2)
 *  [  0 1-star reviews     ](https://wordpress.org/support/plugin/tims-nextcloud-sso-oauth2/reviews/?filter=1)

[Your review](https://wordpress.org/support/plugin/tims-nextcloud-sso-oauth2/reviews/#new-post)

[See all reviews](https://wordpress.org/support/plugin/tims-nextcloud-sso-oauth2/reviews/)

## Contributors

 *   [ Tim Oxendale ](https://profiles.wordpress.org/timssolutions/)

## Support

Got something to say? Need help?

 [View support forum](https://wordpress.org/support/plugin/tims-nextcloud-sso-oauth2/)