Skip to content
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

[Event Hubs] fix auth sample by replacing lambda with callback #16207

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ def generate_sas_token(uri, sas_name, sas_value, token_ttl):
signature = url_parse_quote(base64.b64encode(signed_hmac_sha256.digest()))
return 'SharedAccessSignature sr={}&sig={}&se={}&skn={}'.format(uri, signature, expiry, sas_name)

def on_event(context, event):
print(context.partition_id, ":", event)


class CustomizedSASCredential(object):
def __init__(self, token, expiry):
Expand Down Expand Up @@ -77,6 +80,6 @@ def get_token(self, *scopes, **kwargs):

with consumer_client:
consumer_client.receive(
lambda pc, event: print(pc.partition_id, ":", event),
on_event,
starting_position=-1
)