microsoftgraph / microsoftgraph/msgraph-sdk-java
Authenticate with application id using Certificated-based Authentication
未关闭
@Ndiritu 已经在做这个了。
开始于 2024年7月15日。
Status: Needs Investigation
type:question
- 主要语言
- Java
- 星标
- 444
- 派生
- 154
- 平均合并
- 18 小时 28 分钟
- 30 天内合并 PR
- 4
描述
I registered the app on the Microsoft Entra admin center by referring to this page:
https://learn.microsoft.com/en-us/graph/auth-v2-service?tabs=http
Then I created public/private key using openssl. Here is the commands.
$ openssl genrsa -out ms365-private.key 2048
$ openssl req -new -x509 -key ms365-private.key -out ms365-public.crt -days 365000
Uploaded the public key (ms365-private.key) on the Microsoft Entra admin center, and I created this code.
TokenCredential credential = new ClientCertificateCredentialBuilder().tenantId("xxxxxxxx")
.clientId("xxxxxxxx")
.pemCertificate("/xxxx/xxxxx/ms365-private.key")
.build();
graphClient = new GraphServiceClient(credential);
but if i execute some methods on this graphClient , this following error occurs
[ERROR] com.azure.identity.implementation.util.CertificateUtil.performLogging - PEM certificate provided does not contain -----BEGIN CERTIFICATE-----END CERTIFICATE----- block
java.lang.IllegalArgumentException: PEM certificate provided does not contain -----BEGIN CERTIFICATE-----END CERTIFICATE----- block
at com.azure.identity.implementation.util.CertificateUtil.publicKeyFromPem(CertificateUtil.java:79)
at com.azure.identity.implementation.IdentityClientBase.getConfidentialClient(IdentityClientBase.java:196)
at com.azure.identity.implementation.IdentitySyncClient.lambda$new$2(IdentitySyncClient.java:91)
at com.azure.identity.implementation.SynchronousAccessor.getValue(SynchronousAccessor.java:45)
at com.azure.identity.implementation.IdentitySyncClient.authenticateWithConfidentialClientCache(IdentitySyncClient.java:171)
at com.azure.identity.ClientCertificateCredential.getTokenSync(ClientCertificateCredential.java:150)
at com.microsoft.kiota.authentication.AzureIdentityAccessTokenProvider.getAuthorizationToken(AzureIdentityAccessTokenProvider.java:146)
at com.microsoft.kiota.authentication.BaseBearerTokenAuthenticationProvider.authenticateRequest(BaseBearerTokenAuthenticationProvider.java:46)
Q. Should I also specify public key? If so, how to specify public key by using ClientCertificateCredentialBuilder?
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
评估
这个 Issue 还没有评估数据。