Skip to content

Introduce @me.id and @me.userName to simplify working with the current user #3056

@waldekmastykarz

Description

@waldekmastykarz

Discussed in #3055

Originally posted by waldekmastykarz February 14, 2022
We have commands that require you to specify the user's ID or name. Currently, there's no way to easily specify information about the current user. There are some workarounds like retrieve the user name from the status command. If you need user's ID you'd pass the name to the aad user get command. We could also consider custom implementations in the different commands to introduce specific options like --me. But this is all too cumbersome.

Since we have information about the current user already available in the access token, we could introduce tokens like @me.id and @me.userName that we'd replace with the corresponding information, similarly like we pass content from files. This would free us from having to have command-specific implementations and would make it easier to work with data specific to the current user.

What do you think @pnp/cli-for-microsoft-365-maintainers?

This should be implemented just before we replace @ tokens with file contents:

. In the implementation we need to consider both delegated and app-only auth. @me tokens should work only in delegated mode. In app-only auth they should be replaced with empty values to avoid considering appId a user ID.

Together with this change we should update docs and add a new section after https://pnp.github.io/cli-microsoft365/user-guide/using-cli/#passing-complex-content-into-cli-options that explains which tokens are available and how they can be used.

Checklist:

  • code
  • test
  • docs

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions