title: Access token from ARM expired when received
body: <p>I'm creating an app that creates scheduled jobs programmatically, I am therefore using the REST API provided by Azure. I require an access token but when I authenticate, the access token returned from request expires that same time it is sent to me.</p>
  
  <p>The client id is an application that I registered on Azure AD and copied the Application ID.</p>
  
  <p>I created the secret key in the Keys blade. </p>
  
  <p>I am using the <code>AzureEnvironment.AzureGlobalCloud.AuthenticationEndpoint/{My Azure ID}</code> as the authority (<a href="https://login.microsoftonline.com/" rel="nofollow noreferrer">https://login.microsoftonline.com/</a>)
  I am requesting the access token for Azure Resource manager using <code>AzureEnvironment.AzureGlobalCloud.ResourceManagerEndpoint</code>.</p>
  
  <pre><code>private async Task&lt;string&gt; GetAccessToken()
  {
      _authContext = new AuthenticationContext($"{AzureEnvironment.AzureGlobalCloud.AuthenticationEndpoint}{ _jobConfig.TenantId}");
      var credential = new ClientCredential(_jobConfig.AzureApplicationId, _jobConfig.AzureApplicationSecret);
      var authResult = await _authContext.AcquireTokenAsync(AzureEnvironment.AzureGlobalCloud.ResourceManagerEndpoint, credential);
  
      return authResult.AccessToken;
  }
  </code></pre>
  
  <p><code>_jobconfig</code> is an instance containing the data mentioned above and referenced in the code.</p>
  
  <p><a href="https://i.stack.imgur.com/yyFqG.png" rel="nofollow noreferrer">Debug Data</a></p>