question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Access token for Azure Valid only for 1 hour

See original GitHub issue

Steps to reproduce

Hi @isaiahwilliams I am looking for some guidance. We are using the secure model for partner center but with Azure.

To login to Azure we have the following code:

$azureTokenParameters = @{
            RefreshToken = [System.Runtime.InteropServices.Marshal]::PtrToStringAuto([System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($azRefreshTokenSecure))
            Scopes = 'https://management.azure.com/user_impersonation'
            Credential = $azCredential
            ApplicationId = ''
            TenantId = ''
            ServicePrincipal = $true
            ErrorAction = 'Stop'
        }
        $azureToken = New-PartnerAccessToken @azureTokenParameters

The returned access token we use in Connect-AzAccount. The return access token is valid only for 1 hour though. I have tried doing this: https://docs.microsoft.com/en-us/azure/active-directory/develop/active-directory-configurable-token-lifetimes#cmdlet-reference

The policy that is set is:

$policyDefinition = @('{
    "TokenLifetimePolicy":
        {
            "Version":1,
            "AccessTokenLifetime":"23:00:00"
        }
    }')

Setting AccessTokenLifetime to higher value specifically for the application and for the service principal of the application. Assigning the policy even to both of them does not work as I still get access token of 1 hour with the above command. Can you help us? We need to have access token for longer than one hour because we have workflows that run more than 1 hour. How to do this with the secure model for partner center?

What steps can reproduce the defect? Please share the setup, commandline for vstest.console, sample project, target framework etc.

Expected behavior

Share the expected output

Actual behavior

What is the behavior observed?

Diagnostic logs

Please share test platform diagnostics logs.
The logs may contain test assembly paths, kindly review and mask those before sharing.

Environment

Please share additional details about your environment. Version

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:7

github_iconTop GitHub Comments

1reaction
slavizhcommented, Feb 11, 2020

@isaiahwilliams I was asking more to reach to that team as representative for the of the partners. Last time when I had to convince them to retain non-interactive user authentication I had to battle with them for weeks until they can understand how critical is this for CSP. It is important that there is some collaboration on such initiatives inside Microsoft as my experience shows when I try to reach to multiple groups to solve issue turns into failure unfortunately.

1reaction
ghostcommented, Feb 11, 2020

@slavizh both the Azure and Partner Center modules use a similar strategy for authentication, which means it would not be too difficult add this ability. I know there has been discussions about this topic within the Azure PowerShell team, but I am not aware of any immediate plans. Fortunately that module is open source, so if the team behind module is not planning to add this feature hopefully the community can. Let me see if there is anything additional I can track down.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Configurable token lifetimes - Microsoft Entra
An access token can be used only for a specific combination of user, client, and resource. ... The default lifetime of the token...
Read more >
Azure Data Factories - Renewing Access Tokens every 1 ...
The access token expires every 1 hour. How can I set up this pipeline so that every 50 minutes it will check just...
Read more >
For how long I can keep using the access token?
I know this access token expires in an hour. ... Of course, the new token will not be valid forever, it will expire...
Read more >
How to change token expiration time in Azure portal - AAD
The expiry time of token is approx. 30 mins to 1 hr. Now when this token expires, I am not able to retrieve...
Read more >
Continuous access evaluation in Azure AD
By default, access tokens are valid for one hour, when they expire the client is redirected to Azure AD to refresh them.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found