def get_access_token()

in bonsaicli2/bonsai_cli/aad.py [0:0]


    def get_access_token(self):
        """This is used to get the AAD access token"""

        # attempt to get token from cache
        token = self._get_access_token_from_cache()
        if token:
            return "Bearer {}".format(token["access_token"])

        # no token found in cache, user must sign in and try again
        if use_fake_token():
            token = {"access_token": "dummy"}
        elif use_password_auth():
            token = self._log_in_with_password()
        else:
            print("No access token found in cache, please sign in.")
            self._log_in_with_device_code()
            token = self._get_access_token_from_cache()

        if token:
            return "Bearer {}".format(token["access_token"])

        message = "Error: could not fetch AAD access token after login."
        raise AuthenticationError(message)