File tree Expand file tree Collapse file tree 1 file changed +6
-1
lines changed
Expand file tree Collapse file tree 1 file changed +6
-1
lines changed Original file line number Diff line number Diff line change @@ -842,13 +842,15 @@ def set_default_service_username(self, username=None):
842842 self ._update_session_headers ()
843843
844844 @contextmanager
845- def as_username (self , username ):
845+ def as_username (self , username , ignore_service_error = False ):
846846 """Service API will temporarily work as other user.
847847
848848 This method can be used only if service API key is logged in.
849849
850850 Args:
851851 username (Union[str, None]): Username to work as when service.
852+ ignore_service_error (Optional[bool]): Ignore error when service
853+ API key is not used.
852854
853855 Raises:
854856 ValueError: When connection is not yet authenticated or api key
@@ -861,6 +863,9 @@ def as_username(self, username):
861863 )
862864
863865 if not self ._access_token_is_service :
866+ if ignore_service_error :
867+ yield None
868+ return
864869 raise ValueError (
865870 "Can't set service username. API key is not a service token."
866871 )
You can’t perform that action at this time.
0 commit comments