Netlify-cms: Cannot login with Github, on a live domain, when cms in Open authoring mode, but works fine on localhost

Created on 16 Dec 2020  路  3Comments  路  Source: netlify/netlify-cms

Hello!

Describe the bug
When netlify-cms is setup in open_authoring publishing mode, login with github works locally, but not when the site is live (github page + custom domain).

To Reproduce

(jsbin example)

  • A minimal netlify-cms setup with a repository setup for open authoring, and a default collection (steps here: https://www.netlifycms.org/docs/open-authoring)

When clicking the login with github button, a new browser page opens (not new tab), with the folowing URLs:

  • on localhost: https://api.netlify.com/auth/done?code=7eee<longstring>&state=eyJ0e<longstring>
  • on live: https://api.netlify.com/auth?provider=github&site_id=companies.joblist.city&scope=public_repo

After this, localhost succeeds, and live blocks on a api.netlify.com error:

No Auth Provider Found
Make sure you've configured the API credentials for Github from the Access part of your Netlify site dashboard.

Expected behavior
Able to log in locally and when the site is live, in open authoring mode, and without netlify.com (just netlify-cms open authoring and a github repo).

Applicable Versions:
Tested from latest and down on a few patch/minor versions, it does not seem to work, except locally, where everything is good.

CMS configuration

Additional context

  • The netlify identity widget should not be required as it works locally.
  • (edit) tested with and without github graphql parameter, and both work locally, and not live. Keeping in right now, because it is making a lot less request to the Github api.
open authoring bug

All 3 comments

Hi @hugurp, did you follow step 1 in https://www.netlifycms.org/docs/github-backend linked from https://www.netlifycms.org/docs/open-authoring/?

Using a GitHub backend requires a backend service to facilitate authentication since GitHub doesn't support implicit auth.
You can set one up using Netlify or use one of the community provided solutions.

It works on localhost since Netlify provides a test GitHub OAuth server when running locally to make development easier.

Ah no!
I did not, I thought it did not require the github api middleware, since working in open authoring.
Will try this, and I guess it should work.

Sorry for the wrong-issue then, and thanks for your answer!

The issue above was not a bug but a misunderstanding from my side.

To sum it up:

netlify-cms with open-authoring:

  • needs to use github backend (with or without graphql)
  • this means that you need a backend service for handling user authentication against github api (middleware)
  • for this reason, it is "easier" to host the site serving the netlify-cms instance on netlify.app servers, as it comes with this authentication middleware out of the box (Site settings > Access control > OAuth > Authentication Providers > Install Provider "github" < paste in github app id and private key). Without this middleware it cannot be hosted on github pages (this issue; with or without custom domain).
  • otherwise, you need to host this middleware yourself.

Thanks for your help!

Was this page helpful?
0 / 5 - 0 ratings