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

HTTP error with incorrect username and password #140

Closed
foster82 opened this issue Dec 30, 2018 · 4 comments
Closed

HTTP error with incorrect username and password #140

foster82 opened this issue Dec 30, 2018 · 4 comments

Comments

@foster82
Copy link

Hi ,

I am having problems while doing a confluence search with cql. If the username and password are correct everything is great. However if the username or password are incorrect i get a HTTP error. I want to capture this so it can just display authentication error rather than the full stack out put.

Can you advise where i capture this so that i can handle it as an except. Sorry if this is a little obvious, but i am new to python.

Thanks

Jonathan

@gonchik
Copy link
Member

gonchik commented Jan 7, 2019

Hi!

Sorry for the delay, from atlassian import Confluence
I am using like this

import config
import pprint
import logging

CONFLUENCE_URL = config.CONFLUENCE_URL
CONFLUENCE_LOGIN = config.CONFLUENCE_LOGIN
CONFLUENCE_PASSWORD = config.CONFLUENCE_PASSWORD

logging.basicConfig(level=logging.ERROR)

if __name__ == '__main__':
    confluence = Confluence(
        url=CONFLUENCE_URL,
        username=CONFLUENCE_LOGIN,
        password='blablabla'
    )
    pprint.pprint(confluence.cql('text ~ gonchik'))

then output will be like this
image

Otherwise we can implement other exception module.

Cheers,
Gonchik Tsymzhitov

@foster82
Copy link
Author

great thanks that has helped to a degree , what i am looking do do though is hide this out put. Is that possible? Just need to show an authentication error.

@Woklex
Copy link
Contributor

Woklex commented Apr 11, 2019

You can just throw a request and check that we are fine.

    confluence = Confluence(
        url=CONFLUENCE_URL,
        username=CONFLUENCE_LOGIN,
        password='blablabla'
    )
    out = confluence.request()
    if out.status_code == 200:
        confluence.cql('text ~ Wubba lubba dub dub!'))
    elif out.status_code == 401:
        print("AUTHENTICATED_FAILED")
    else:
        print("Another error. Do something.")

@gonchik
Copy link
Member

gonchik commented May 4, 2019

@Woklex Thanks for that.
| have implemented here as well
dfd882b

@gonchik gonchik closed this as completed May 4, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants