def get_gitlab(): """Return a logged-in instance of the gitlab client. Authenticate the client. If the authentication fails with an Unauthorized error, ask the user to provide the token again and retry. """ gitlab = GitlabClient() try: gitlab.login(get_token(gitlab.url)) except Unauthorized, e: print "Could not authenticate with Gitlab: {}".format(e.message) print "It looks like your token is wrong." reset_token() return get_gitlab()
def auth(): """Reset the authentication token.""" reset_token()