Graph API dowload URL expires too quickly

Nadjim 61 Reputation points
2022-06-21T13:15:18.003+00:00

Hi :),

I use an Graph API application to have the download link of a file from my sharepoint, but i have a problem.

In fact, the link expires too quickly (1 hour) because the token expires in 1 hour too.

I would like to know if there is a solution for my case because, I saw that we could no longer configure the expiration time of a token

Best regards

Microsoft 365 and Office SharePoint For business Windows
Microsoft Security Microsoft Entra Microsoft Entra ID
Microsoft Security Microsoft Graph
0 comments No comments
{count} votes

3 answers

Sort by: Most helpful
  1. Vicky Kumar (Mindtree Consulting PVT LTD) 1,161 Reputation points Microsoft Employee
    2022-06-21T20:25:55.767+00:00

    Hi @Nadjim

    This is due the token expiry time, this is valid for about one hour, as the documentation mentioned.
    213390-image.png
    And client credential flow will not issue refresh tokens, the client can make the same call again to obtain a new access token.
    by the way, you can extend the lifetime of the access token by configuring the access token lifetime policy, but the maximum lifetime of the token still cannot exceed 24 hours.

    So if you want to get refresh token the only way is to use auth code flow or ROPC flow.

    0 comments No comments

  2. Alfredo Revilla - Upwork Top Talent | IAM SWE SWA 27,526 Reputation points Moderator
    2022-06-21T21:28:31.97+00:00

    Hello @Nadjim , actually you can extend the lifetime of an access token however and for security reasons it's recommended to keep it short. In order to obtain a new access token without re-entering your credentials you can obtain and use a refresh token which lifetime can last from 24 hours to 90 days.

    Let us know if this answer was helpful to you or if you need additional assistance. If it was helpful, please remember to accept it so that others in the community with similar questions can more easily find a solution.

    0 comments No comments

  3. RaytheonXie_MSFT 40,471 Reputation points Microsoft External Staff
    2022-06-22T05:57:43.95+00:00

    Hi @Nadjim ,
    Per my research, I do agree with VickyKumarMindtreeConsultingPVTLTD-5545 and alfredorevilla-msft's answer. You can set token lifetimes for all apps in your organization, for a multi-tenant (multi-organization) application, or for a specific service principal in your organization. Please refer to the following document to set your lifetimes

    https://learn.microsoft.com/en-us/azure/active-directory/develop/configure-token-lifetimes


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.



Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.