New Sample: Ensure the Site Assets library is created#1447
New Sample: Ensure the Site Assets library is created#1447phillipharding wants to merge 1 commit intopnp:devfrom phillipharding:sample-ensuresiteassetslibrary
Conversation
|
Thank you! We'll review it shortly! 👏 |
waldekmastykarz
left a comment
There was a problem hiding this comment.
Very nice! Let's clarify one thing and then we can get it in 👍
|
|
||
| try { | ||
| $resource = ($siteUrl -split "/")[2] | ||
| $accessToken = o365 util accesstoken get --new --resource "https://$resource/" |
There was a problem hiding this comment.
Is there a specific reason why you always retrieve a new access token here rather than using one retrieved previously if still valid?
There was a problem hiding this comment.
Not really, just being cautious and not understanding when/how access tokens are refreshed by the CLI, this function could be called at some point during a long provisioning pipeline which may not have included SharePoint to that point - happy to remove it
There was a problem hiding this comment.
Gotcha, we should do better job explaining the details in our docs. The way it works, is that each time you request a token, the CLI will check if the previously available token is still valid. If it is, it returns it. If it expired, it will automatically retrieve a new one. So in practice, you should need the --new switch only if you granted additional permissions or need a different token.
|
|
||
| try { | ||
| $resource = ($siteUrl -split "/")[2] | ||
| $accessToken = o365 util accesstoken get --new --resource "https://$resource/" |
There was a problem hiding this comment.
AAD resources, with one exception, typically don't have a trailing slash. In this case it doesn't matter, but there are cases in which it returns an invalid access token
There was a problem hiding this comment.
Good to know, shall I remove it?
There was a problem hiding this comment.
I can remove it when merging the PR. No problem 👍
|
Merged manually. Thank you! Welcome to the crew! 👏 🍾 🎉 |
Ensure the Site Assets library is created
There are occasions when creating a new modern SharePoint site using the CLI/REST API that the Site Assets library isn't created, use this script to ensure that the Site Assets library is created.
Reference: 'ensure' commands #1427