Ejemplo n.º 1
0
 def tokens(self):
     if not self.__tokens:
         try:
             self.__tokens = self.__native_client.load_tokens_by_scope(
                 requested_scopes=self.scopes
             )
         except fair_research_login.LoadError:
             raise exc.NotLoggedIn("Client has no tokens, either call login() "
                                   "or supply tokens to client on init.")
     return self.__tokens
Ejemplo n.º 2
0
 def login(self, **login_kwargs):
     """Login to the cfde-submit client. This will ensure the user has the correct
     tokens configured but it DOES NOT guarantee they are in the correct group to
     run a flow. Can be run both locally and on a server.
     See help(fair_research_login.NativeClient.login) for a full list of kwargs.
     """
     logger.info("Initiating Native App Login...")
     logger.debug(f"Requesting Scopes: {self.scopes}")
     login_kwargs["requested_scopes"] = login_kwargs.get("requested_scopes", self.scopes)
     try:
         self.__native_client.login(**login_kwargs)
     except fair_research_login.LoginException as le:
         raise exc.NotLoggedIn(f"Unable to login: {str(le)}") from le
Ejemplo n.º 3
0
 def tokens(self, new_tokens):
     # Check tokens, if supplied outside of client
     if new_tokens and set(new_tokens) != set(self.scopes):
         raise exc.NotLoggedIn("Tokens supplied to CfdeClient are invalid, "
                               f"They MUST match {self.scopes}")