Skip to content

Adds 'cli accesstoken refresh' command. Closes #6681 - #7719

Open
joseimsss wants to merge 1 commit into
pnp:mainfrom
joseimsss:feat/issue-6681-cli-accesstoken-refresh
Open

joseimsss wants to merge 1 commit into
pnp:mainfrom
joseimsss:feat/issue-6681-cli-accesstoken-refresh

Conversation

@joseimsss

Copy link
Copy Markdown

Closes #6681

Summary

Adds the new m365 cli accesstoken refresh command to explicitly refresh cached access tokens (all cached tokens by default, or a specific token when -r, --resource [resource] is provided, including the sharepoint and graph shorthand identifiers).

Changes

  • src/m365/cli/commands.ts: registered ACCESSTOKEN_REFRESH in alphabetical order.
  • src/m365/cli/commands/accesstoken/accesstoken-refresh.ts: implemented CliAccessTokenRefreshCommand with optional -r, --resource option, sharepoint/graph shorthand resolution, and forced token acquisition via auth.ensureAccessToken(resource, logger, this.debug, true).
  • src/m365/cli/commands/accesstoken/accesstoken-refresh.spec.ts: added unit tests with 100% statement, branch, function, and line coverage.
  • eslint.config.mjs: added 'refresh' to the command-name word-breaking dictionary.
  • docs/docs/cmd/cli/accesstoken/accesstoken-refresh.mdx & docs/src/config/sidebars.ts: added command documentation (including a clear note that only scopes already consented on the service principal are reflected) and registered it in the sidebar.
  • docs/docs/cmd/cli/app/app-reconsent.mdx: referenced m365 cli accesstoken refresh in the remarks section.

Validation

  • npm run build: passed.
  • npm run lint: passed with 0 errors.
  • Targeted coverage (c8 on dist/m365/cli/commands/accesstoken/accesstoken-refresh.js): 13 passing, 100% Statements (78/78), 100% Branches (20/20), 100% Functions (5/5), 100% Lines (78/78).
  • npm run test:test: 17208 passing (run on Node v23.11.0; npm test version check requires Node 26).

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The new command is missing from the clim365 skill’s command index, preventing its discovery through index searches.

1 open issue
What changed in this PR

Adds m365 cli accesstoken refresh to refresh cached Microsoft 365 access tokens without signing out, addressing #6681.

Changes:

  • Refreshes all cached resources or a selected resource, with sharepoint and graph shorthand support.
  • Adds command registration, validation, logging, error handling, and unit tests.
  • Documents usage and consent requirements, and links the command from app reconsent guidance.

Build, tests, and lint were not run during this review.

File Description
src/​m365/​cli/​commands/​accesstoken/​accesstoken-refresh.ts Implements forced token refresh and resource selection.
src/​m365/​cli/​commands/​accesstoken/​accesstoken-refresh.spec.ts Tests validation, resource selection, empty caches, and errors.
src/​m365/​cli/​commands.ts Registers the new command name.
eslint.config.mjs Adds refresh to the command-name dictionary.
docs/​src/​config/​sidebars.ts Adds the command to documentation navigation.
docs/​docs/​cmd/​cli/​app/​app-reconsent.mdx Links token refresh guidance after consent updates.
docs/​docs/​cmd/​cli/​accesstoken/​accesstoken-refresh.mdx Documents options, examples, and consent requirements.

Review effort: Balanced

Comment thread src/m365/cli/commands.ts
const prefix: string = 'cli';

export default {
ACCESSTOKEN_REFRESH: `${prefix} accesstoken refresh`,
@milanholemans

Copy link
Copy Markdown
Contributor

@joseimsss can you please let the issue be assigned to you first before working on it?

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

New command: cli accesstoken refresh

3 participants