Python REST JIRA How to test for valid authentication?

I’m using the following code below. How do you check for a valid authentication? If I give it a valid email it works fine but if I give it a bad one it doesn’t error. Only thing is that later queries say

The value ‘IT’ does not exist for the field ‘project’.
Field ‘IT Queue’ does not exist or this field cannot be viewed by anonymous users.

Is there some way I can either get an error about an invalid login OR something in the returning JSON I can check to ensure the login is correct?

from atlassian import Jira

_JIRA_API_KEY = 'xxxxxx' #
_JIRA_URL = ''

class MyJira():
    def __init__(self, user):

        j = Jira(

        self.jira = j

j = MyJira('')

You’ve tried with a specific endpoint that has anonymous access allowed what means, that even if authorisation fails, you request would be proceeded as for a user who is not logged it. This is why you get such an error code.

The solution would be to try with another endpoint that is not available for not logged in user. ie. /rest/api/3/myself. (

Let me know if it helps.