gpt4 book ai didi

Java 服务总线共享访问 token

转载 作者:行者123 更新时间:2023-12-01 21:44:24 26 4
gpt4 key购买 nike

Configuration config =
ServiceBusConfiguration.configureWithSASAuthentication(
URL,
"RootManageSharedAccessKey",
token,
".servicebus.windows.net"
);

这是java服务总线实现的配置代码。我有兴趣传递共享访问签名而不是共享访问 key 。我不确定 java azure sdk 的实现是否支持此功能。我具体该怎么做呢。当我在 token 变量中使用共享访问签名 token 时,我不断收到 401 未经授权的错误。有什么想法吗?

最佳答案

根据source code在 Azure Service Bus SDK for Java 中,函数 configureWithSASAuthentication 的四个参数应为 namespacesasKeyNamesasKey & serviceBusRootUri(默认传递“.servicebus.windows.net”)。

namespacesasKeyNamesasKey 您可以通过单击底部的CONNECTION INFORMATION 按钮找到它们您的服务总线,请参见下图。

图 1. 服务总线页面底部的 CONNECTION INFORMATION 按钮 enter image description here

图 2. 复制 CONNECTION STRING 并提取命名空间、sasKeyName 和 sasKey enter image description here

例如,连接字符串为 Endpoint=sb://abc-ns.servicebus.windows.net/;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=ABCdefg123!@#=,则 namespacesasKeyNamesasKey 分别是 abc-nsRootManageSharedAccessKeyABCdefg123 !@#=.

所以代码应该如下。

Configuration config =
ServiceBusConfiguration.configureWithSASAuthentication(
"abc-ns",
"RootManageSharedAccessKey",
"ABCdefg123!@#=",
".servicebus.windows.net"
);

您还可以在服务总线页面的CONFIGURE选项卡中找到它们,请参见下图。

图 3.CONFIGURE 选项卡 enter image description here

关于Java 服务总线共享访问 token ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36116266/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com