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

getting this error while running program. #1

Open
praffuln opened this issue Jan 3, 2022 · 1 comment
Open

getting this error while running program. #1

praffuln opened this issue Jan 3, 2022 · 1 comment

Comments

@praffuln
Copy link

praffuln commented Jan 3, 2022

Exception in thread "main" com.microsoft.graph.core.ClientException: Error executing the request
at com.microsoft.graph.http.CoreHttpProvider.sendRequestInternal(CoreHttpProvider.java:406)
at com.microsoft.graph.http.CoreHttpProvider.send(CoreHttpProvider.java:222)
at com.microsoft.graph.http.CoreHttpProvider.send(CoreHttpProvider.java:199)
at com.microsoft.graph.http.BaseCollectionRequest.send(BaseCollectionRequest.java:102)
at com.microsoft.graph.http.BaseEntityCollectionRequest.get(BaseEntityCollectionRequest.java:78)
at com.phantomartist.email.handler.impl.MessageHandlerImpl.getUnread(MessageHandlerImpl.java:33)
at com.phantomartist.email.EmailProcessor.run(EmailProcessor.java:43)
at com.phantomartist.email.App.main(App.java:56)
Caused by: java.io.IOException: java.util.concurrent.ExecutionException: com.microsoft.aad.msal4j.MsalServiceException: AADSTS1002012: The provided value for scope openid profile offline_access User.Read.All User.Read Mail.ReadBasic.All Mail.Read email is not valid. Client credential flows must have a scope value with /.default suffixed to the resource identifier (application ID URI).
Timestamp: 2022-01-03 16:57:11Z
at com.microsoft.graph.httpcore.AuthenticationHandler.intercept(AuthenticationHandler.java:65)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
at com.microsoft.graph.httpcore.TelemetryHandler.intercept(TelemetryHandler.java:68)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
at okhttp3.internal.connection.RealCall.getResponseWithInterceptorChain$okhttp(RealCall.kt:201)
at okhttp3.internal.connection.RealCall.execute(RealCall.kt:154)
at com.microsoft.graph.http.CoreHttpProvider.sendRequestInternal(CoreHttpProvider.java:403)
... 7 more
Caused by: java.util.concurrent.ExecutionException: com.microsoft.aad.msal4j.MsalServiceException: AADSTS1002012: The provided value for scope openid profile offline_access User.Read.All User.Read Mail.ReadBasic.All Mail.Read email is not valid. Client credential flows must have a scope value with /.default suffixed to the resource identifier (application ID URI).
Trace ID: 9956e7a6-6522-4827-8697-b8fae2f2e701
Correlation ID: 36df62ff-4171-47c2-842d-ee5697a1873f
Timestamp: 2022-01-03 16:57:11Z
at java.util.concurrent.CompletableFuture.reportGet(CompletableFuture.java:357)
at java.util.concurrent.CompletableFuture.get(CompletableFuture.java:1895)
at com.microsoft.graph.httpcore.AuthenticationHandler.intercept(AuthenticationHandler.java:55)
... 13 more
Caused by: com.microsoft.aad.msal4j.MsalServiceException: AADSTS1002012: The provided value for scope openid profile offline_access User.Read.All User.Read Mail.ReadBasic.All Mail.Read email is not valid. Client credential flows must have a scope value with /.default suffixed to the resource identifier (application ID URI).
Trace ID: 9956e7a6-6522-4827-8697-b8fae2f2e701
Correlation ID: 36df62ff-4171-47c2-842d-ee5697a1873f
Timestamp: 2022-01-03 16:57:11Z
at com.microsoft.aad.msal4j.MsalServiceExceptionFactory.fromHttpResponse(MsalServiceExceptionFactory.java:43)
at com.microsoft.aad.msal4j.TokenRequestExecutor.createAuthenticationResultFromOauthHttpResponse(TokenRequestExecutor.java:96)
at com.microsoft.aad.msal4j.TokenRequestExecutor.executeTokenRequest(TokenRequestExecutor.java:37)
at com.microsoft.aad.msal4j.AbstractClientApplicationBase.acquireTokenCommon(AbstractClientApplicationBase.java:120)
at com.microsoft.aad.msal4j.AcquireTokenByAuthorizationGrantSupplier.execute(AcquireTokenByAuthorizationGrantSupplier.java:63)
at com.microsoft.aad.msal4j.AcquireTokenByClientCredentialSupplier.acquireTokenByClientCredential(AcquireTokenByClientCredentialSupplier.java:58)
at com.microsoft.aad.msal4j.AcquireTokenByClientCredentialSupplier.execute(AcquireTokenByClientCredentialSupplier.java:44)
at com.microsoft.aad.msal4j.AuthenticationResultSupplier.get(AuthenticationResultSupplier.java:59)
at com.microsoft.aad.msal4j.AuthenticationResultSupplier.get(AuthenticationResultSupplier.java:17)
at java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1590)
at java.util.concurrent.CompletableFuture$AsyncSupply.exec(CompletableFuture.java:1582)
at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289)
at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1056)
at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1692)
at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:157)

@phantom-artist
Copy link
Owner

phantom-artist commented Jan 6, 2022

The app is designed to be run with Application permissions in the app registration portal, not Delegated permissions, since it's effectively a daemon and does not have a signed-in user. See https://docs.microsoft.com/en-us/azure/active-directory/develop/v2-permissions-and-consent#permission-types

The code was written as a quick exercise to demonstrate the graph API to a colleague (hence lack of unit tests) and hasn't been fully validated, so there may be additional tweaks required to get it to work - particularly around the security setup. I think there are issues with the AuthenticationBuilder - it needs additional scopes and some adjustments to get the right token. If I get time I'll see if I can update it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants