MS Graph API:JWT 令牌无效。令牌已过期
MS Graph API: Invalid JWT token. The token is expired
使用MS Graph API driveItem: preview driveItem: preview在线编辑word文档
在 iframe
中显示 MS Word 网页 URL:
<iframe id="imagepgframe" src="https://purushothamchowdary-my.sharepoint.com/personal/purushotham_purushothamchowdary_onmicrosoft_com/_layouts/15/PreAuth.aspx?sourcedoc={289e7b7a-e5d3-43dc-957a-5564ca9faeb9}&action=edit#access_token=eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsIng1dCI6IkcydDJKYzlkMVZ6RkdjdzZUZy02YUhZVXk2VSJ9%2EeyJhdWQiOiJ3b3BpL3B1cnVzaG90aGFtY2hvd2RhcnktbXkuc2hhcmVwb2ludC5jb21AZTZmMjQ4NWYtYTY4My00MzZlLThmZmEtMWQ3OWVkMjFmYWQwIiwiaXNzIjoiMDAwMDAwMDMtMDAwMC0wZmYxLWNlMDAtMDAwMDAwMDAwMDAwQDkwMTQwMTIyLTg1MTYtMTFlMS04ZWZmLTQ5MzA0OTI0MDE5YiIsIm5iZiI6IjE2MTE5MDM0NDQiLCJleHAiOiIxNjExOTAzNzQ0IiwibmFtZWlkIjoiMTAwMzIwMDEwYTNiNGM0MyIsIm5paSI6InVybjpmZWRlcmF0aW9uOm1pY3Jvc29mdG9ubGluZSIsImNhY2hla2V5IjoiMGguZnxtZW1iZXJzaGlwfDEwMDMyMDAxMGEzYjRjNDNAbGl2ZS5jb20iLCJpc3VzZXIiOiJ0cnVlIiwiYWNycyI6IltcInVybjp1c2VyOnJlZ2lzdGVyc2VjdXJpdHlpbmZvXCIsXCJ1cm46bWljcm9zb2Z0OnJlcTFcIixcInVybjptaWNyb3NvZnQ6cmVxMlwiLFwidXJuOm1pY3Jvc29mdDpyZXEzXCIsXCJjMVwiLFwiYzJcIixcImMzXCIsXCJjNFwiLFwiYzVcIixcImM2XCIsXCJjN1wiLFwiYzhcIixcImM5XCIsXCJjMTBcIixcImMxMVwiLFwiYzEyXCIsXCJjMTNcIixcImMxNFwiLFwiYzE1XCIsXCJjMTZcIixcImMxN1wiLFwiYzE4XCIsXCJjMTlcIixcImMyMFwiLFwiYzIxXCIsXCJjMjJcIixcImMyM1wiLFwiYzI0XCIsXCJjMjVcIl0iLCJhcHBpZCI6IjNhODhmMmUzLTY4NjktNDA4YS1hZTAzLTE2YjQ0OTdlMWQxNyIsInRpZCI6ImU2ZjI0ODVmLWE2ODMtNDM2ZS04ZmZhLTFkNzllZDIxZmFkMCIsImlwYWRkciI6IjE1Ny40MS4xNDIuMTQ2Iiwid29waV9hcCI6ImFsbGZpbGVzLndyaXRlIiwid29waV90dCI6IlByZUF1dGhUb2tlbiIsImFwcGN0eCI6IjI4OWU3YjdhZTVkMzQzZGM5NTdhNTU2NGNhOWZhZWI5O3ZYam1GZUVqbHNqeE0xWnkzMU9mRVZpSkFFMD07RGVmYXVsdDs7MTAyQjAzQzIzOTJFRjtUcnVlOzszYTg4ZjJlMy02ODY5LTQwOGEtYWUwMy0xNmI0NDk3ZTFkMTc7Njg7YjJmZWY4MTYtMTE4YS00N2I4LWFlMTItMTA2NzJhMDA2ZGRiIn0%2EOjcVqrRRrFrG6YNacnl2h32Hd1exc30YMGhrTdhJ2nSxhciaYqrMWkhLUMz7hDxyONMtgHVUzBty%2DNP2WUtDibf%2DKzOCTTW9aF01ytp%5FQTqIikpdDLUkyXQwDuJQzKuZh8vjxSXF5jfYtoK7JyqUNXZfllozebrqXe80arK%2DTNvvqAk3tOqF5yBedEYW0KrIIyFlyPNXNMyxdGBNEvRjMpMBqzE0Pn3wBiWeh6q4Bx8qSCYE9HwObPDUNtw%2DtCZh%2DFx6suS%5F3kuntWjyxKOqYRfYWpt%5FrWwFCxbFvWwThG5JcT1RUWHi0vdvA9%2DVGn%5FMUqxuKr9BQjUaQC9SFIhaMw"></iframe>
正在将 word 文档文件上传到 OneDrive。在获取网络的应用程序中 URL 在浏览器中打开 word 文档。
预览 Link :
https://graph.microsoft.com/beta/me/drive/items/01ZPAXLBD2POPCRU7F3RBZK6SVMTFJ7LVZ/preview
问题:
如果用户在网页中闲置几分钟并访问网页中的任何link,系统显示
`{"error_description":"Invalid JWT token. The token is expired."}` instead of word editor embedded in `iframe`
官方文档说的很清楚:
This action allows you to obtain short-lived embeddable URLs for
an item in order to render a temporary preview.
If you want to obtain long-lived embeddable links, use the
createLink API instead.
此端点仅提供一个短暂的可嵌入 URL。
我们可以发现返回的link中有一个access_token
(getUrl
):
https://tenant-my.sharepoint.com/personal/allenwu_tenant_onmicrosoft_com/_layouts/15/embed.aspx?uniqueId=ef*****c-e100-4dcd-a47c-f9c2c*****88&access_token=eyJ0eXAiOiJKV1QiLCJhbGciOiJ***
如果你在https://jwt.io, you will get the exp
claim which means the expiration time of the access token. Copy the value of exp
and convert it to date in this link: https://timestamp.online/中解码它。然后我们可以看到这个access token的实际生命周期是5分钟左右。
因此用户保持空闲,然后出现 Invalid JWT token. The token is expired.
错误。符合预期。
如果您想获得长期可嵌入links,请按照文档建议使用createLink API。
使用MS Graph API driveItem: preview driveItem: preview在线编辑word文档
在 iframe
中显示 MS Word 网页 URL:
<iframe id="imagepgframe" src="https://purushothamchowdary-my.sharepoint.com/personal/purushotham_purushothamchowdary_onmicrosoft_com/_layouts/15/PreAuth.aspx?sourcedoc={289e7b7a-e5d3-43dc-957a-5564ca9faeb9}&action=edit#access_token=eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsIng1dCI6IkcydDJKYzlkMVZ6RkdjdzZUZy02YUhZVXk2VSJ9%2EeyJhdWQiOiJ3b3BpL3B1cnVzaG90aGFtY2hvd2RhcnktbXkuc2hhcmVwb2ludC5jb21AZTZmMjQ4NWYtYTY4My00MzZlLThmZmEtMWQ3OWVkMjFmYWQwIiwiaXNzIjoiMDAwMDAwMDMtMDAwMC0wZmYxLWNlMDAtMDAwMDAwMDAwMDAwQDkwMTQwMTIyLTg1MTYtMTFlMS04ZWZmLTQ5MzA0OTI0MDE5YiIsIm5iZiI6IjE2MTE5MDM0NDQiL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JhMDA2ZGRiIn0%2EOjcVqrRRrFrG6YNacnl2h32Hd1exc30YMGhrTdhJ2nSxhciaYqrMWkhLUMz7hDxyONMtgHVUzBty%2DNP2WUtDibf%2DKzOCTTW9aF01ytp%5FQTqIikpdDLUkyXQwDuJQzKuZh8vjxSXF5jfYtoK7JyqUNXZfllozebrqXe80arK%2DTNvvqAk3tOqF5yBedEYW0KrIIyFlyPNXNMyxdGBNEvRjMpMBqzE0Pn3wBiWeh6q4Bx8qSCYE9HwObPDUNtw%2DtCZh%2DFx6suS%5F3kuntWjyxKOqYRfYWpt%5FrWwFCxbFvWwThG5JcT1RUWHi0vdvA9%2DVGn%5FMUqxuKr9BQjUaQC9SFIhaMw"></iframe>
正在将 word 文档文件上传到 OneDrive。在获取网络的应用程序中 URL 在浏览器中打开 word 文档。
预览 Link :
https://graph.microsoft.com/beta/me/drive/items/01ZPAXLBD2POPCRU7F3RBZK6SVMTFJ7LVZ/preview
问题:
如果用户在网页中闲置几分钟并访问网页中的任何link,系统显示
`{"error_description":"Invalid JWT token. The token is expired."}` instead of word editor embedded in `iframe`
官方文档说的很清楚:
This action allows you to obtain short-lived embeddable URLs for an item in order to render a temporary preview.
If you want to obtain long-lived embeddable links, use the createLink API instead.
此端点仅提供一个短暂的可嵌入 URL。
我们可以发现返回的link中有一个access_token
(getUrl
):
https://tenant-my.sharepoint.com/personal/allenwu_tenant_onmicrosoft_com/_layouts/15/embed.aspx?uniqueId=ef*****c-e100-4dcd-a47c-f9c2c*****88&access_token=eyJ0eXAiOiJKV1QiLCJhbGciOiJ***
如果你在https://jwt.io, you will get the exp
claim which means the expiration time of the access token. Copy the value of exp
and convert it to date in this link: https://timestamp.online/中解码它。然后我们可以看到这个access token的实际生命周期是5分钟左右。
因此用户保持空闲,然后出现 Invalid JWT token. The token is expired.
错误。符合预期。
如果您想获得长期可嵌入links,请按照文档建议使用createLink API。