Hi all,
currently I am using the following code to login to JIRA using python:
... jira = JIRA(options=jira_options, basic_auth=(user,pass)) ...
Let's say the user provided wrong username or password. How do I know what is the reason of failed login ?
How do I catch that ?
Ah, actually it looks like you are using the jira-python library? In this case it looks like you can rely on the HTTP Status code and look for a code of 401 to indicate a login failure. Here's an example:
from jira import JIRA from jira.exceptions import JIRAError options = { 'server': 'http://localhost:2990/jira' } try: jira = JIRA(options=options, basic_auth=('fred', 'blargh')) except JIRAError as e: if e.status_code == 401: print "Login to JIRA failed. Check your username and password" print "done!"
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
The HTTP response from JIRA will contain a HTTP header called X-Seraph-LoginReason
. If the header has a value of OK
, then the login was successful. If the header is absent, or contains any other value, then the login failed.
Note that if the JIRA instance is using a custom authenticator (such as if some kind of SSO integration is enabled), then different rules will be in effect at the full discretion of the specific authenticator.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Joe Clark [Atlassian],
can you please include some simple example showing how to deal with it ?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.