【发布时间】:2019-09-25 06:21:44
【问题描述】:
例如,我可以通过 getaccesstokencredentials(username, password) 通过图形 api 进行身份验证 我可以使用此令牌访问 Azure 吗? 目前我们可以使用管理库中的 usertokencredentials 和 applicationtokencredentials,然后一旦完成,您就可以创建 azure 类的实例。 Azure azure = Azure.authenticate(credentials).withdefaultsubscription。 我想知道我们是否可以使用 getaccesstokencredentials 中的令牌而不是 usertokentcredentials 和 applicationtokencredentials
【问题讨论】:
-
能否提供调用graph api的代码或提供重新分级
getaccesstokencredentials的文档? -
这是通过gazure graph获取访问令牌的代码
-
getAccessTokenFromUserCredentials(String uname, String pwd) 抛出异常 { AuthenticationContext ctx; AuthenticationResult res; ExecutorService 服务 = null;尝试 { service = Executors.newFixedThreadPool(1); ctx=new AuthenticationContext(AUTHORITY, false, service); Future
future = context.acquireToken("graph.microsoft.com", appid, uname, pwd, null); res=future.get(); } res 结果; } -
删除了一些因为它很长
-
我们使用以下代码在 azure 中进行身份验证: UserTokenCredentials creds = new UserTokenCredentials( CLIENT_ID, domain, username, password, AzureEnvironment.AZURE); Azure azureAuth = Azure.authenticate(creds).withDefaultSubscription();我正在考虑使用通过图形 api 生成的令牌而不是来自 usertokencredentials 的令牌,因为如果我使用 usertokencredentials 进行身份验证,我会遇到“invalid_grant”问题,但是在使用图形时它是成功的
标签: java azure azure-storage-account