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' # https://id.atlassian.com/manage-profile/security/api-tokens
_JIRA_URL = 'https://mysite.atlassian.net'

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

        j = Jira(
            url=_JIRA_URL,
            username=user,
            password=_JIRA_API_KEY,
            cloud=True)

        self.jira = j

j = MyJira('xxxx@yyyy.com')

Hi!
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. (https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-myself/#api-rest-api-3-myself-get)

Let me know if it helps.
Regards,
Beata