Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot access Confluence (invalid Confluence URL or authentication failure reported) #848

Closed
MiaLiu1993 opened this issue Oct 8, 2023 · 10 comments
Labels
connection-issues Issues trying to talk with a Confluence instance question A generic inquiry

Comments

@MiaLiu1993
Copy link

confluence_server_url, confluence_server_user, confluence_space_key are correct, but Sphinx cannot access Confluence during building:
image

or

image

@jdknight
Copy link
Member

jdknight commented Oct 9, 2023

If you can navigate to the Confluence URL printed in that message via a web browser with no issues, the next thing to check would be to try fetch the same URL with a command (depending on your host):

curl <URL>
 or
wget -qO- <URL>
 or
Invoke-WebRequest -Uri <URL>

This could help rule our possible local proxy configurations or help identify some sort of remote proxy setup for the Confluence instance you may be trying to interact with.

Typically, the first error shown is an indication of a remote system forcefully dropping/ignoring the request. This could be many things ~ the configure URL is not a Confluence-hosted instance, the REST pipe is configured to block traffic or more.

The second error is a "HTTP 401 Unauthorized" response provided by the URL you are trying to query against. For a target Confluence instance, such a response is typically an indication that the expected credential information is incorrect. Is this a Cloud or Server instance? Using API tokens (since you have indicated you have set a username; so no PAT) or just a raw password?

Maybe try generating a report and output this information here:

python -m sphinxcontrib.confluencebuilder report

@karedinvs
Copy link

karedinvs commented Oct 25, 2023

Hi,

Have the same issue and tested with different confluence organisations, different py versions, different sphinx versions, different base os

I would be grateful for any help

The queries below are successful

curl https://MYDOMAIN.atlassian.net/wiki/
Found. Redirecting to https://MYDOMAIN.atlassian.net/login?application=confluence&dest-url=%2Fwiki%2F%

curl -v https://MYDOMAIN.atlassian.net/wiki/ --user USER:TOKEN

fetching configuration information...
Running Sphinx v5.3.0
myst v0.18.1: MdParserConfig(commonmark_only=False, gfm_only=False, enable_extensions=[], disable_syntax=[], all_links_external=False, url_schemes=('http', 'https', 'mailto', 'ftp'), ref_domains=None, highlight_code_blocks=True, number_code_blocks=[], title_to_header=False, heading_anchors=None, heading_slug_func=None, footnote_transition=True, words_per_minute=200, sub_delimiters=('{', '}'), linkify_fuzzy_links=True, dmath_allow_labels=True, dmath_allow_space=True, dmath_allow_digits=True, dmath_double_inline=False, update_mathjax=True, mathjax_classes='tex2jax_process|mathjax_process|math|output_area')
connecting to confluence instance...
ERROR: Traceback (most recent call last):
  File "/usr/local/Caskroom/miniconda/base/envs/clds_38/lib/python3.8/site-packages/sphinxcontrib/confluencebuilder/cmd/report.py", line 147, in report_main
    publisher.connect()
  File "/usr/local/Caskroom/miniconda/base/envs/clds_38/lib/python3.8/site-packages/sphinxcontrib/confluencebuilder/publisher.py", line 71, in connect
    rsp = self.rest_client.get('space', {
  File "/usr/local/Caskroom/miniconda/base/envs/clds_38/lib/python3.8/site-packages/sphinxcontrib/confluencebuilder/rest.py", line 108, in _wrapper
    return func(self, *args, **kwargs)
  File "/usr/local/Caskroom/miniconda/base/envs/clds_38/lib/python3.8/site-packages/sphinxcontrib/confluencebuilder/rest.py", line 150, in _wrapper
    return func(self, *args, **kwargs)
  File "/usr/local/Caskroom/miniconda/base/envs/clds_38/lib/python3.8/site-packages/sphinxcontrib/confluencebuilder/rest.py", line 242, in get
    self._handle_common_request(rsp)
  File "/usr/local/Caskroom/miniconda/base/envs/clds_38/lib/python3.8/site-packages/sphinxcontrib/confluencebuilder/rest.py", line 372, in _handle_common_request
    raise ConfluencePermissionError('rest-call')
sphinxcontrib.confluencebuilder.exceptions.ConfluencePermissionError: 
---
Permission denied on Confluence (rest-call)

The configured user does not have permission to perform an action on the
Confluence instance. If the user should have access and this request is
using a personal access token, ensure the token is not expired/revoked.
---



Confluence builder report has been generated.
Please copy the following text for the GitHub issue:

------------[ cut here ]------------

(system)
platform: macOS-10.16-x86_64-i386-64bit
python: 3.8.0 (default, Nov 6 2019, 15:49:01) [Clang 4.0.1 (tags/RELEASE_401/final)]
sphinx: 5.3.0
docutils: 0.17.1
requests: 2.31.0
builder: 2.3.0

(configuration)
confluence_publish: True
confluence_publish_token: (set)
confluence_server_url: https:// (cloud)
confluence_space_key: (set; user)

(confluence instance)
connected: no

------------[ cut here ]------------
---

fetching configuration information...
Running Sphinx v5.3.0
myst v0.18.1: MdParserConfig(commonmark_only=False, gfm_only=False, enable_extensions=[], disable_syntax=[], all_links_external=False, url_schemes=('http', 'https', 'mailto', 'ftp'), ref_domains=None, highlight_code_blocks=True, number_code_blocks=[], title_to_header=False, heading_anchors=None, heading_slug_func=None, footnote_transition=True, words_per_minute=200, sub_delimiters=('{', '}'), linkify_fuzzy_links=True, dmath_allow_labels=True, dmath_allow_space=True, dmath_allow_digits=True, dmath_double_inline=False, update_mathjax=True, mathjax_classes='tex2jax_process|mathjax_process|math|output_area')
connecting to confluence instance...

Confluence builder report has been generated.
Please copy the following text for the GitHub issue:

------------[ cut here ]------------

(system)
platform: Linux-3.13.0-48-generic-x86_64-with-glibc2.2.5
python: 3.8.16 (default, Jan 18 2023, 02:52:32) [GCC 10.2.1 20210110]
sphinx: 5.3.0
docutils: 0.17.1
requests: 2.31.0
builder: 2.3.0

(configuration)
confluence_publish: True
confluence_publish_token: (set)
confluence_server_url: https:// (cloud)
confluence_space_key: (set; user)

(confluence instance)
connected: no

------------[ cut here ]------------
ERROR: Traceback (most recent call last):
  File "/usr/src/app/.venv/lib/python3.8/site-packages/sphinxcontrib/confluencebuilder/cmd/report.py", line 147, in report_main
    publisher.connect()
  File "/usr/src/app/.venv/lib/python3.8/site-packages/sphinxcontrib/confluencebuilder/publisher.py", line 71, in connect
    rsp = self.rest_client.get('space', {
  File "/usr/src/app/.venv/lib/python3.8/site-packages/sphinxcontrib/confluencebuilder/rest.py", line 108, in _wrapper
    return func(self, *args, **kwargs)
  File "/usr/src/app/.venv/lib/python3.8/site-packages/sphinxcontrib/confluencebuilder/rest.py", line 150, in _wrapper
    return func(self, *args, **kwargs)
  File "/usr/src/app/.venv/lib/python3.8/site-packages/sphinxcontrib/confluencebuilder/rest.py", line 242, in get
    self._handle_common_request(rsp)
  File "/usr/src/app/.venv/lib/python3.8/site-packages/sphinxcontrib/confluencebuilder/rest.py", line 372, in _handle_common_request
    raise ConfluencePermissionError('rest-call')
sphinxcontrib.confluencebuilder.exceptions.ConfluencePermissionError: 
---
Permission denied on Confluence (rest-call)

The configured user does not have permission to perform an action on the
Confluence instance. If the user should have access and this request is
using a personal access token, ensure the token is not expired/revoked.
---


Updates:

When I use the parameters confluence_ask_user = True and confluence_ask_password = True and manually enter the values using the API token instead of the password value, the upload goes fine.

If I set the parameter(confluence_server_user, confluence_server_password or confluence_publish_token) values in conf.py, it doesn't work.

@jdknight
Copy link
Member

@karedinvs, it looks to me that are you using a Confluence Cloud instance with API tokens; however, the key confluence_publish_token is being set, which is for PAT (personal access tokens) on Confluence data center/server instances. In theory, if you set the field confluence_server_user to the username associated with an API token with the confluence_server_pass field as the API token value, it should be able to authenticate.

@karedinvs
Copy link

@jdknight Thank you for your response.

it looks to me that are you using a Confluence Cloud instance with API tokens;

Yes

I have tried many options. Authentication is successful only when entering the account username and user token manually. If I provide them using parameters, authentication is not successful. I see no other explanation except that this is some kind of bug.

@karedinvs
Copy link

@jdknight your experience and expertise is required. We would be very grateful if you could help us find the problem. We have made many attempts - no success

@jdknight
Copy link
Member

jdknight commented Nov 9, 2023

@karedinvs, just to clarify, since you are using API tokens, you are not using confluence_publish_token; right?

@karedinvs
Copy link

karedinvs commented Nov 10, 2023

@jdknight to clarify:

  1. I have created PAT
  2. I have set username to confluence_server_user (but what about this note?
Note
If using a personal access token (PAT), this option does not need to set (see confluence_publish_token)

and this one
If attempting to use a personal access token (PAT), use the confluence_publish_token option instead.
)
3) PAT to confluence_server_pass as you suggested above

and got this message

sphinxcontrib.confluencebuilder error:

---
Unable to authenticate with Confluence

Unable to authenticate with the Confluence instance. Ensure the
configured username and password are correct. If credentials appear to
be correct, the user may need to be unlocked be re-logging in with above
browser or asking an administrator of the Confluence instance for help.
---

I don't get why when I use the parameter

confluence_ask_password = True

Everything works fine

@jdknight
Copy link
Member

Sorry @karedinvs, I am a bit confused on some of your responses. Above you have indicated that you are using API tokens, but at the same time you have also indicated that you are creating PATs. These are two different authentication methods provided by Confluence (unless Confluence has recently changed support for these two token types).

From the messages you have indicated above, I am under the assumption that you are using API tokens and not PATs. This is due to your original comment indicating that using confluence_ask_user/confluence_ask_password works for you. Note that the input provided by confluence_ask_user gets copied into confluence_server_user; likewise for confluence_ask_password gets copied into confluence_server_pass.

I would make sure in your test configuration that:

  • confluence_server_user is set to the user that created the API token;
  • confluence_server_pass is set to the value of the API token; and,
  • confluence_publish_token is not set.

And after configuring this, run python -m sphinxcontrib.confluencebuilder report to verify that the user/pass values are (set), and the publish-token configuration is not listed.

@karedinvs
Copy link

@jdknight hi
I apologise for the long delay in replying
I used confluence_server_password instead of confluence_server_pass
many thanks for your assistance

@jdknight jdknight added the question A generic inquiry label Jan 29, 2024
@jdknight
Copy link
Member

It is believed that OP has either addressed their issue or is no longer pursuing. Unknown if the other investigation with connection issues was associated from OP, but since that issue was resolved, there no longer appears to be any more support requests here. With that in mind, marking this issue as closed.

@jdknight jdknight added the connection-issues Issues trying to talk with a Confluence instance label Feb 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
connection-issues Issues trying to talk with a Confluence instance question A generic inquiry
Projects
None yet
Development

No branches or pull requests

3 participants