- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我在 Azure AD 租户中注册了应用程序,这些应用程序具有 clientid 和 key 。我需要获取 azure 应用程序凭据的到期日期。我在我的应用程序中使用azure sdk for java。我们如何使用 java 获取客户端 secret 的到期日期?
我用谷歌搜索过,但没有找到任何有用的链接。谁能帮我解决这个问题。
最佳答案
如果您想在 Java 应用程序中获取 secret 到期日期,您可以调用 Microsoft Graph API获取应用程序。然后应用程序的属性passwordCredentials有信息。例如
使用 Azure 门户注册新应用程序
使用工作或学校帐户登录 Azure 门户,或者个人 Microsoft 帐户。
如果您的帐户允许您访问多个租户,请在右上角选择您的帐户,然后将您的门户 session 设置为所需的 Azure AD 租户。
在左侧导航 Pane 中,选择 Azure Active Directory 服务,然后选择应用注册 > 新注册。
代码
//install ADAL4J get accesss token
String clientId = "your application id";
String appKey = "your client secret";
String tenantId = "your tenant id";
String authority =String.format("https://login.microsoftonline.com/",getTenantContextId())
String resourceUrl = "https://graph.microsoft.com"
ExecutorService service = Executors.newFixedThreadPool(1);
AuthenticationContext context = ew AuthenticationContext(authority, false, service);
ClientCredential clientCred = new ClientCredential(
clientId, appKey);
Future<AuthenticationResult> future = context.acquireToken(resourceUrl, clientCred, null);
AuthenticationResult result = future.get();
//Call Microsoft graph api
String stringUrl ="https://graph.microsoft.com/beta/applications?$filter=appId eq '{ApplicationId}'";
URL url = new URL(stringUrl.replaceAll(" ","%20"));
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setRequestMethod("GET");
conn.setRequestProperty("Authorization", "Bearer " + result.getAccessToken());
conn.setRequestProperty("Accept", "application/json");
conn.setRequestProperty("Content-Type", "application/json");
int httpResponseCode = conn.getResponseCode();
if (httpResponseCode == 200 ) {
BufferedReader in = null;
StringBuilder response;
in = new BufferedReader(
new InputStreamReader(conn.getInputStream()));
String inputLine;
response = new StringBuilder();
while ((inputLine = in.readLine()) != null) {
response.append(inputLine);
}
in.close();
JSONObject jb = new JSONObject(response.toString());
更多详情请引用document
请使用以下代码获取访问 token
String authority = "https://login.microsoftonline.com/" + tenant;
ExecutorService service = Executors.newFixedThreadPool(1);
AuthenticationContext context = new AuthenticationContext(authority, true, service);
ClientCredential cred = new ClientCredential(clientId, clientSecret);
String resourceId ="https://graph.microsoft.com";
Future<AuthenticationResult> future = context.acquireToken(resourceId, cred, null);
AuthenticationResult result = future.get();
String accesstoken = result.getAccessToken();
关于java - 如何在java中获取客户端 key 到期日期,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57556944/
通过Dropbox oAuth2 API获取的访问 token 的生存期是多少? https://api.dropbox.com/1/oauth2/token之后的答案类似于 { "acces
在 Braintree 中,当我生成带有 $customerId 的客户端 token 时,将该客户端 token 保存到数据库并在以后重新使用它有多可靠? 我总是有一个用户对应一个 $custome
我是新手,正在尝试编写一个简单的登录应用程序。当我离开登录页面一段时间并输入用户名和密码时,它不会登录,而是会执行 session 过期行为。我检查了日志,发现每当我收到 INFO - Session
我想导航到刷新 token 过期时的登录 View 。我如何在Android中使用 OkHttp 处理这种情况。刷新 token 到期时,服务器以错误代码 403禁止的响应。有什么方法可以处理刷新 t
我想知道 Backbone 模型/ Controller 是否有一种标准方法来处理 session 结束。我正在使用 node.js 作为我的 webapp 的后端,现在我将 session 存储在内
我正在使用 https://www.paypal.com/cgi-bin/webscr 用于进行 PayPal 付款。当任何用户点击 PayNow 按钮时,它将导航到用户输入其凭据的 PayPal 页
我们最近注册了一个 iOS Enterprise 帐户用于内部应用分发。 搜索论坛发现两件事我想得到确认: 1- 企业分发证书有效期为 3 年。这是否意味着我们需要在此时使用新证书重新构建应用程序,否
我遇到了一个奇怪的场景。基本上在我正在做的每个网页上 session_start(); if(!isset($_SESSION['login'])) header("Location: log
有许多工具可用于监控通过 HTTPS 提供的服务的 SSL 过期,例如我们使用 https://github.com/prometheus/blackbox_exporter当 SSL 证书在内部和外
我正在使用 Vapor 4 开发一个 Web 应用程序。在请求之间一次将客户端制作的数据保存在服务器端几分钟会很有用。我想使用 session 来做到这一点。但是,我对如何在设定时间后自动销毁这些数据
我正在使用带有自定义身份验证的 firebase 9.x。根据文档, token 到期时间不能超过一小时。是否有一个我可以注册的监听器,当 token 过期时将调用它。 该文档还讨论了 token 的
正在关注 http://code.google.com/apis/gmail/oauth/protocol.html#imap我正在尝试为使用 OAuth 的 Gmail 实现 IMAP 客户端。 我
试图确定是否由对 Accounts.sendResetPasswordEmail() 的调用生成的 token 将永远过期。我在 accounts-password 上找不到任何进一步的文档。包超出了
编辑:我对这本书的当前状态不感兴趣。这是各种结账的历史记录。 实际上,整个问题可能格式错误,无法回答。但无论如何我得到了答案,这很好。我主要是在寻找WHEN -> THEN结构。 我有books可以检
根据我的理解,在使用 Drive Java API 时,建议构建一个 Drive 类的实例,然后存储它,以便其他线程可以共享它。如果持有对 Drive 实例的引用的进程是一个长时间运行的进程(即无限期
我读到的关于 cookie 的所有内容都说,将 cookie 的到期时间设置为零应该使其成为“ session ”cookie,浏览器将在退出时将其删除。 http://www.cookiecentr
我正在制作一个使用jwt来验证数据库调用的 Angular 应用程序。 就是当 token 在服务器上过期时,由于过期的 token 仍在本地存储中,因此应用程序开始提供空白页而不是数据。经过一些研究
我在grails应用程序中使用spring安全性。在其他浏览器上使用相同的用户名登录时,我需要使上一个 session 到期。并发 session 限制是否有帮助?这该怎么做? 最佳答案 I need
当我向手机发送推送通知时遇到了麻烦,它返回了以下错误: [X-SubscriptionStatus] => Expired [X-NotificationStatus] => Dropped [X-D
我需要创建一个用户登录/注销/ session 到期跟踪页面(ASP.Net)..很明显,当用户登录和注销时,我可以调用我的跟踪页面。如何检测 session 过期? 最佳答案 在有状态应用程序中,最
我是一名优秀的程序员,十分优秀!