web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id : WB14GV9MoeZvMP5C5abrvB
Power Automate - Building Flows
Answered

Get user activity via HTTP request.

Like (0) ShareShare
ReportReport
Posted on 10 Jan 2023 16:12:06 by 26

Hello all,

what should be the HTTP query to retrieve the login activity of a specific user?

ektoplasma24_0-1673366934865.png

 

My app is authorized in AAD as follows, 

ektoplasma24_1-1673367010508.png

 

 

The audit log is also enabled.

 

  • ektoplasma24 Profile Picture
    26 on 26 Jul 2023 at 06:30:23
    Re: Get user activity via HTTP request.

    Hi @HouJun , 

     

    try,

     

    GET - https://graph.microsoft.com/v1.0/users/{user-id}/licenseDetails

     

    put the user-id inside the brackets. 

     

    For the request you need one of the follwing permissions:

    • Directory.Read.All
    • Directory.ReadWrite.All
    • User.Read
    • User.Read.All
    • User.ReadWrite.All

     

    Kind regards. 


     

     

  • HouJun Profile Picture
    14 on 18 Jul 2023 at 12:46:11
    Re: Get user activity via HTTP request.

    HI,Expiscornovus
    Do you know how to get the license information owned by a specific user from AAD?
    If you know, please tell me.
    Thanks

  • ektoplasma24 Profile Picture
    26 on 10 Jan 2023 at 17:48:47
    Re: Get user activity via HTTP request.

    @Expiscornovus 

    I've deleted the HTTP Action and set it up again, now it works.

    Thanks for your ambitions.❤️

    Now you have a new follower 😋

  • Verified answer
    Expiscornovus Profile Picture
    32,182 Most Valuable Professional on 10 Jan 2023 at 17:41:35
    Re: Get user activity via HTTP request.

    Hi @ektoplasma24,

     

    Just tested the signinActivity resource one. If it helps below is my setup and my test result. So, in theory it should work for you as well. Just need to find what is different in your setup.

     

    Below is my test setup.

     

    lastsignin02.png

     

    2. My test result

     

    lastsignin.png

  • ektoplasma24 Profile Picture
    26 on 10 Jan 2023 at 17:36:43
    Re: Get user activity via HTTP request.

    @Expiscornovus 

    Tenant-ID and Client ID are correct - checked them twice 😅

    ektoplasma24_0-1673372187244.png

     

  • Expiscornovus Profile Picture
    32,182 Most Valuable Professional on 10 Jan 2023 at 17:29:02
    Re: Get user activity via HTTP request.

    Hi @ektoplasma24,

     

    There is a lot more to troubleshoot. For example, what type of authentication have you configured in the Authentication settings of the HTTP action?

     

    Since you were talking about an App, I assume you are using OAuth in the HTTP action configuration?

     

    Have you double checked you are using the correct client id, client secret, tenant id, etc.? 

     

    adappreg.png

     

     

     

  • ektoplasma24 Profile Picture
    26 on 10 Jan 2023 at 17:28:51
    Re: Get user activity via HTTP request.

    @Expiscornovus 

    I've got the same error as in the last post. 

    I only would like to know when the user has logged in the last time..  seems to be difficult 😂

  • ektoplasma24 Profile Picture
    26 on 10 Jan 2023 at 17:21:26
    Re: Get user activity via HTTP request.

    Hi, @Expiscornovus

    thanks for your help, I think there is not much left to solve this puzzle. 😄
    I got another error, I think that is because I was not registered as an app owner. - changed that now.
    Subsequently, I've triggered the workflow again unfortunately without success the error remains... 

    ektoplasma24_0-1673371178225.png

    URL is now, 

    https://graph.microsoft.com/beta/users/6da38f53-ff1d-445b-8a06-262cc******/?$select=displayName,userPrincipalName,signInActivity

     

    Error message, 

    {
     "error": {
     "code": "Authentication_MSGraphPermissionMissing",
     "message": "Calling principal does not have required MSGraph permissions AuditLog.Read.All",
     "innerError": {
     "date": "2023-01-10T17:13:05",
     "request-id": "bf8158c3-bee3-40d8-8941-f3456011a25d",
     "client-request-id": "bf8158c3-bee3-40d8-8941-f3456011a25d"
     }
     }
    }
  • Expiscornovus Profile Picture
    32,182 Most Valuable Professional on 10 Jan 2023 at 17:07:35
    Re: Get user activity via HTTP request.

    Hi @ektoplasma24,

     

    And in case you are talking about audit logs signIns, you could use the below. I really need some coffee 😅

     

     

    https://graph.microsoft.com/v1.0/auditlogs/signIns?$filter=userId eq 'youruserid'

     

  • Expiscornovus Profile Picture
    32,182 Most Valuable Professional on 10 Jan 2023 at 17:03:35
    Re: Get user activity via HTTP request.

    Hi @ektoplasma24,

     

    Apologies for the confusion. I forgot it is a beta method and the property is called signInActivity, not signIn:

    https://learn.microsoft.com/en-us/azure/active-directory/reports-monitoring/howto-manage-inactive-user-accounts#how-to-detect-inactive-user-accounts

     

     

    Try something like below:

     

    https://graph.microsoft.com/beta/users/youruserid/?$select=displayName,userPrincipalName,signInActivity

     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Announcing our 2025 Season 2 Super Users!

A new season of Super Users has arrived, and we are so grateful for…

Paul Stork – Community Spotlight

We are honored to recognize Paul Stork as our July 2025 Community…

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 497 Super User 2025 Season 2

#2
David_MA Profile Picture

David_MA 436 Super User 2025 Season 2

#3
Riyaz_riz11 Profile Picture

Riyaz_riz11 244 Super User 2025 Season 2

Loading complete