Skip to content

Refresh token doesn't work #2

@ViValentin

Description

@ViValentin

Hello,

Great functions to simplify Graph API access.
Never the less it seems I have an issue using it to loop on all our AD (on prem) users and collecting their signin information.
After around one hour running I have error saying "message": "Access token has expired.",
He are the line of my code extracting the UserID from AD UPN and then requesting for beta signin informations

        $URI = "https://graph.microsoft.com/v1.0/users/" + $User.UserPrincipalName + "?`$select=id
        $ID = (Invoke-MSGraphQuery -URI $URI -token $token -tokenrefresh -credential $credential -tenantID $TenantId).id
        $URI = "https://graph.microsoft.com/beta/users/" + $ID + "?`$select=userPrincipalName, signInActivity"
        $SignInData = Invoke-MSGraphQuery -URI $URI -token $token -tokenrefresh -credential $credential -tenantID $TenantId | select -ExpandProperty Value

What I miss so that it doesn't refresh the token after one hour?
Thanks for help

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions