following microsoft graph doc and cannot make user recent activity api work

Youssef Gabr 1 Reputation point
2022-11-21T23:03:21.147+00:00

at first I followed the docs on how to create an app with Microsoft graph using java

here and it works fine now I tried to add a user activity API to my java project I only followed the tutorial here
The code I wrote from the tutorial for the user activity api logs this output in the console

Nov 22, 2022 12:47:01 AM com.azure.core.util.logging.ClientLogger performDeferredLogging  
INFO: Azure Identity => getToken() result for scopes [user.read, mail.read, mail.send]: SUCCESS  

then it freezes for ten minutes then gives me this error

Nov 20, 2022 2:55:35 PM com.azure.core.util.logging.ClientLogger performDeferredLogging INFO: Azure Identity => getToken() result for scopes [user.read, mail.read, mail.send]: SUCCESS Nov 20, 2022 3:04:39 PM com.microsoft.graph.logger.DefaultLogger logError SEVERE: CoreHttpProvider[sendRequestInternal] - 409Graph service exception Error code: UnknownError Nov 20, 2022 3:04:39 PM com.microsoft.graph.logger.DefaultLogger logError SEVERE: CoreHttpProvider[sendRequestInternal] - 409Error message: {"Message":"Request limit exceeded for Authentication Failure"} Nov 20, 2022 3:04:39 PM com.microsoft.graph.logger.DefaultLogger logError SEVERE: CoreHttpProvider[sendRequestInternal] - 409 Nov 20, 2022 3:04:39 PM com.microsoft.graph.logger.DefaultLogger logError SEVERE: CoreHttpProvider[sendRequestInternal] - 409GET https://graph.microsoft.com/v1.0/me/activities/microsoft.graph.recent?%24top=1&%24orderby=lastModifiedDateTime%20DESC Nov 20, 2022 3:04:39 PM com.microsoft.graph.logger.DefaultLogger logError SEVERE: CoreHttpProvider[sendRequestInternal] - 409SdkVersion : graph-java/v5.22.0 Nov 20, 2022 3:04:39 PM com.microsoft.graph.logger.DefaultLogger logError SEVERE: CoreHttpProvider[sendRequestInternal] - 409 Nov 20, 2022 3:04:39 PM com.microsoft.graph.logger.DefaultLogger logError SEVERE: CoreHttpProvider[sendRequestInternal] - 409 Nov 20, 2022 3:04:39 PM com.microsoft.graph.logger.DefaultLogger logError SEVERE: CoreHttpProvider[sendRequestInternal] - 409429 :  Nov 20, 2022 3:04:39 PM com.microsoft.graph.logger.DefaultLogger logError SEVERE: CoreHttpProvider[sendRequestInternal] - 409[...] Nov 20, 2022 3:04:39 PM com.microsoft.graph.logger.DefaultLogger logError SEVERE: CoreHttpProvider[sendRequestInternal] - 409 Nov 20, 2022 3:04:39 PM com.microsoft.graph.logger.DefaultLogger logError SEVERE: CoreHttpProvider[sendRequestInternal] - 409[Some information was truncated for brevity, enable debug logging for more details] Nov 20, 2022 3:04:39 PM com.microsoft.graph.logger.DefaultLogger logError SEVERE: Throwable detail: com.microsoft.graph.http.GraphServiceException: Error code: UnknownError Error message: {"Message":"Request limit exceeded for Authentication Failure"}  GET https://graph.microsoft.com/v1.0/me/activities/microsoft.graph.recent?%24top=1&%24orderby=lastModifiedDateTime%20DESC SdkVersion : graph-java/v5.22.0   429 :  [...]  

I am new to graph apis so I don't know why this api call takes so long I think it tries to make too much requests but I only followed the tutorial and dont know why it does that is says authentication failure although I have given the access rights to this api as per the docs

Delegated (work or school account)

UserActivity.ReadWrite.CreatedByApp

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
11,318 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Shivam Dhiman 5,951 Reputation points
    2022-11-22T00:26:55.007+00:00

    Hi @Youssef Gabr

    As per this documentation, UserActivity.ReadWrite.CreatedByApp permission is required to run this https://graph.microsoft.com/v1.0/me/activities/microsoft.graph.recent Graph API endpoint.
    262738-perm.png

    From the information you have provided, I can see that this permission is missing from the scope.
    Please add the respective permission and check if you are still facing this issue.

    Hope this helps.

    If the answer is helpful, please click Accept Answer and kindly upvote. If you have any further questions about this answer, please click Comment.