-
Notifications
You must be signed in to change notification settings - Fork 138
multi app token workflow (started from allow to create clients with different dapr-api-token ) #856
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 3 commits
5c7fc54
43b0b68
46c78ec
aa3ef52
b092daa
0f6edfa
828544a
f7547a6
9b78558
2fa1ff2
465209c
bca1f9c
cd7f34c
ebcdf1b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -141,6 +141,7 @@ def __init__( | |||||
| ] = None, | ||||||
| max_grpc_message_length: Optional[int] = None, | ||||||
| retry_policy: Optional[RetryPolicy] = None, | ||||||
| api_token: Optional[str] = None, | ||||||
| ): | ||||||
| """Connects to Dapr Runtime and initialize gRPC client stub. | ||||||
|
|
||||||
|
|
@@ -152,8 +153,13 @@ def __init__( | |||||
| StreamStreamClientInterceptor, optional): gRPC interceptors. | ||||||
| max_grpc_message_length (int, optional): The maximum grpc send and receive | ||||||
| message length in bytes. | ||||||
| api_token (str, optional): Dapr API token for authentication. If not provided, | ||||||
| falls back to DAPR_API_TOKEN environment variable. | ||||||
| """ | ||||||
| DaprHealth.wait_until_ready() | ||||||
| self._api_token = api_token | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why don't set
Suggested change
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. sure, makes sense, I'll make changes in a commit as it covers more than just this line |
||||||
| # For health check, use explicit token or fall back to global setting | ||||||
| health_token = api_token if api_token is not None else settings.DAPR_API_TOKEN | ||||||
| DaprHealth.wait_until_ready(api_token=health_token) | ||||||
| self.retry_policy = retry_policy or RetryPolicy() | ||||||
|
|
||||||
| useragent = f'dapr-sdk-python/{__version__}' | ||||||
|
|
@@ -184,10 +190,12 @@ def __init__( | |||||
| else: | ||||||
| interceptors.append(DaprClientTimeoutInterceptorAsync()) | ||||||
|
|
||||||
| if settings.DAPR_API_TOKEN: | ||||||
| # Use explicit token if provided, otherwise fall back to global setting | ||||||
| token = self._api_token if self._api_token is not None else settings.DAPR_API_TOKEN | ||||||
| if token: | ||||||
| api_token_interceptor = DaprClientInterceptorAsync( | ||||||
| [ | ||||||
| ('dapr-api-token', settings.DAPR_API_TOKEN), | ||||||
| ('dapr-api-token', token), | ||||||
| ] | ||||||
| ) | ||||||
| interceptors.append(api_token_interceptor) | ||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -52,6 +52,7 @@ def __init__( | |
| host: Optional[str] = None, | ||
| port: Optional[str] = None, | ||
| logger_options: Optional[LoggerOptions] = None, | ||
| api_token: Optional[str] = None, | ||
| ): | ||
| address = getAddress(host, port) | ||
|
|
||
|
|
@@ -61,10 +62,12 @@ def __init__( | |
| raise DaprInternalError(f'{error}') from error | ||
|
|
||
| self._logger = Logger('DaprWorkflowClient', logger_options) | ||
| self._api_token = api_token | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does this need to go to
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the underscore prefix usually hints to tell people that the variable is
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. But the
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see what you mean, like why make is it part of the instance of the object. true, let me check |
||
|
|
||
| metadata = tuple() | ||
| if settings.DAPR_API_TOKEN: | ||
| metadata = ((DAPR_API_TOKEN_HEADER, settings.DAPR_API_TOKEN),) | ||
| token = self._api_token if self._api_token is not None else settings.DAPR_API_TOKEN | ||
| if token: | ||
| metadata = ((DAPR_API_TOKEN_HEADER, token),) | ||
| options = self._logger.get_options() | ||
| self.__obj = client.TaskHubGrpcClient( | ||
| host_address=uri.endpoint, | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.