pnp / cli-microsoft365

Manage Microsoft 365 and SharePoint Framework projects on any platform
https://aka.ms/cli-m365
MIT License
921 stars 325 forks source link

Enhancement: Add extra resources for `util accesstoken get` #4669

Closed milanholemans closed 1 year ago

milanholemans commented 1 year ago

Currently when I want an accesstoken for Graph I have to run m365 util accesstoken get --resource https://graph.microsoft.com. For SharePoint I can just run m365 util accesstoken get --resource sharepoint. To me it would be useful if we add another named resource for Graph so you can use m365 util accesstoken get --resource graph to get a graph token.

Also noticed that we support sharepoint as resource value, but this isn't included in the docs. The only way to know this if you look at one of the examples. Therefore I also suggest that we also add these named resources to the description of the resource option in the docs.

Suggested resources to add:

Resource Endpoint
graph https://graph.microsoft.com
nicodecleyre commented 1 year ago

That's an excellent idea! Have you considered using tokens for the resource option similar to how we use them for the m365 request command? Specifically, utilizing the @graph and @spo tokens.

milanholemans commented 1 year ago

That's an excellent idea! Have you considered using tokens for the resource option similar to how we use them for the m365 request command? Specifically, utilizing the @graph and @spo tokens.

Yeah, I know that you can send requests using m365 request, but I'm more a Postman guy 😊 When trying to clear things out how a certain API endpoint works, Postman is way more convenient to toggle headers, parameters, edit JSON body, ... Also support syntax highlighting etc.

nicodecleyre commented 1 year ago

That's an excellent idea! Have you considered using tokens for the resource option similar to how we use them for the m365 request command? Specifically, utilizing the @graph and @spo tokens.

Yeah, I know that you can send requests using m365 request, but I'm more a Postman guy 😊 When trying to clear things out how a certain API endpoint works, Postman is way more convenient to toggle headers, parameters, edit JSON body, ... Also support syntax highlighting etc.

What I actually mean is using the tokens in this command, for example: m365 util accesstoken get --resource @graph

m365 util accesstoken get --resource @spo

milanholemans commented 1 year ago

What I actually mean is using the tokens in this command, for example: m365 util accesstoken get --resource @graph

m365 util accesstoken get --resource @spo

Aw ok. Well because we already support sharepoint as resource right now, I'm afraid that will be a breaking change.

martinlingstuyl commented 1 year ago

Yes, and I'm not sure what we would gain from that setup as opposed to the autocomplete values we currently have. I'd say, let's keep those.

martinlingstuyl commented 1 year ago

But I like the idea @milanholemans! Should we add autocomplete prefab values for all resources we currently expose? (PowerApps as well, for example)

milanholemans commented 1 year ago

But I like the idea @milanholemans! Should we add autocomplete prefab values for all resources we currently expose? (PowerApps as well, for example)

Was kinda thinking the same 🙂

milanholemans commented 1 year ago

But I like the idea @milanholemans! Should we add autocomplete prefab values for all resources we currently expose? (PowerApps as well, for example)

Updated the specs with some extra resources which I think are the most useful.

waldekmastykarz commented 1 year ago

Should it be o365management or m365management?

waldekmastykarz commented 1 year ago

Personally, I find powerapps and powerplatform not obvious. If you told me you've got this token and asked me which endpoints they use, I wouldn't be able to tell you. Not sure if it's different with folks who use these APIs more often, but I wonder if we're not going too far here. @appieschot, any experience you could share here?

milanholemans commented 1 year ago

Should it be o365management or m365management?

According to the docs and Azure, it's still called O365 image

If you told me you've got this token and asked me which endpoints they use, I wouldn't be able to tell you. Not sure if it's different with folks who use these APIs more often, but I wonder if we're not going too far here.

Yes while writing them down, I kinda had the same feeling tbh.

martinlingstuyl commented 1 year ago

We could add an explanatory section to the docs.. I'm sure that if you work with these endpoints, it's kind of easy to use it this way as soon as you know it. Plus it doesn't hinder other folks, as it's autocompleted anyway.

appieschot commented 1 year ago

Personally, I find powerapps and powerplatform not obvious. If you told me you've got this token and asked me which endpoints they use, I wouldn't be able to tell you. Not sure if it's different with folks who use these APIs more often, but I wonder if we're not going too far here. @appieschot, any experience you could share here?

Purely semantics I know the difference, working in a real life scenario I spend most time working with solutions that contains Power Automate and Power Apps, having to switch would take mental effort.

Sample: work with an app that does something on button press, might want to read some props on that specific action. Could be both inline in the App or a Power Automate process that gets fired.

I do like the idea however and wouldn't be surprised is we move more to a single PowerPlatform token 💡

waldekmastykarz commented 1 year ago

Purely semantics I know the difference, working in a real life scenario I spend most time working with solutions that contains Power Automate and Power Apps, having to switch would take mental effort.

In this case it's more the API to which these tokens maps. Is it obvious which one either of these tokens are mapped to?

milanholemans commented 1 year ago

If it's not clear enough we can remove the power platform and power apps resources. Actually I'm also in doubt that the o365 management API resource will be used.

martinlingstuyl commented 1 year ago

I'd say: just add every possible resource we use and show a table in the docs how these map to apis. Why not? But maybe I'm starting to repeat myself. :)

milanholemans commented 1 year ago

I'd say: just add every possible resource we use and show a table in the docs how these map to apis. Why not? But maybe I'm starting to repeat myself. :)

Also fine for me 😅

waldekmastykarz commented 1 year ago

I'd say: just add every possible resource we use and show a table in the docs how these map to apis. Why not?

Why should we? Just because we use an API, doesn't mean that folks will use it either. If we need a table of mappings between resources and tokens, do we make things easier or harder? I wouldn't add tokens just for the sake of adding them. I suggest that we start with those that we see being used the most and add more when the need arises.

milanholemans commented 1 year ago

I'd say: just add every possible resource we use and show a table in the docs how these map to apis. Why not?

Why should we? Just because we use an API, doesn't mean that folks will use it either. If we need a table of mappings between resources and tokens, do we make things easier or harder? I wouldn't add tokens just for the sake of adding them. I suggest that we start with those that we see being used the most and add more when the need arises.

I that case, we only add Graph as resource right? We could also add O365 management API endpoint, but according to me, this will never be used (used to fetch audit logs).

waldekmastykarz commented 1 year ago

I that case, we only add Graph as resource right? We could also add O365 management API endpoint, but according to me, this will never be used (used to fetch audit logs).

Correct, only Graph. In this case, I suggest we rely on user demand and wait until someone asks for other resources and can share a use case that we don't address with a specific command already.

milanholemans commented 1 year ago

Updated the specs, thank you!

dojcsakj commented 1 year ago

Can I work on this?

milanholemans commented 1 year ago

yes definitely @dojcsakj!

dojcsakj commented 1 year ago

Please, discard abeecd0 - sorry.