@@ -687,17 +687,147 @@ You can create Auth0 resources non-interactively.
687687
688688## Troubleshooting
689689
690- ### ` grace auth login ` fails and mentions refresh tokens
691-
692- Ensure:
690+ ### ` grace auth login ` fails and mentions refresh tokens
691+
692+ Ensure:
693693
694694* the Auth0 API has ** Allow Offline Access** enabled
695- * the Auth0 Native app allows refresh tokens and is configured to issue them
696- * ` grace__auth__oidc__cli_scopes ` includes ` offline_access `
697-
698- ### Headless environments / CI
699-
700- Use:
695+ * the Auth0 Native app allows refresh tokens and is configured to issue them
696+ * ` grace__auth__oidc__cli_scopes ` includes ` offline_access `
697+
698+ ### ` grace status ` returns ` Unauthorized ` and Grace.Server logs look empty
699+
700+ This usually means the CLI sent branch status requests without a usable token.
701+
702+ Common causes:
703+
704+ * No interactive token is cached yet.
705+ * ` GRACE_TOKEN ` is not set (or is invalid).
706+ * You are expecting endpoint handler logs, but the request is rejected by authentication middleware first.
707+
708+ Quick checks:
709+
710+ PowerShell:
711+
712+ ``` powershell
713+ grace auth status --output Verbose
714+ grace auth token status --output Verbose
715+ grace status --output Verbose
716+ ```
717+
718+ bash / zsh:
719+
720+ ``` bash
721+ grace auth status --output Verbose
722+ grace auth token status --output Verbose
723+ grace status --output Verbose
724+ ```
725+
726+ If ` GRACE_TOKEN ` is false and interactive token is false, authenticate first:
727+
728+ PowerShell:
729+
730+ ``` powershell
731+ grace auth login --auth device
732+ # or
733+ grace auth login --auth pkce
734+ ```
735+
736+ bash / zsh:
737+
738+ ``` bash
739+ grace auth login --auth device
740+ # or
741+ grace auth login --auth pkce
742+ ```
743+
744+ If you are using a PAT:
745+
746+ PowerShell:
747+
748+ ``` powershell
749+ $env:GRACE_TOKEN="grace_pat_v1_..."
750+ grace auth token status --output Verbose
751+ ```
752+
753+ bash / zsh:
754+
755+ ``` bash
756+ export GRACE_TOKEN=" grace_pat_v1_..."
757+ grace auth token status --output Verbose
758+ ```
759+
760+ Why logs may look empty:
761+
762+ * ` grace status ` maps to ` branch status ` , which calls ` /branch/Get ` and ` /branch/GetParentBranch ` .
763+ * Those routes require authentication and are rejected with ` 401 ` before business handlers run.
764+ * You might see little or no endpoint-level logging for these failures.
765+
766+ Where to look for proof of ` 401 ` :
767+
768+ * W3C request logs under ` %TEMP%\Grace.Server.Logs ` (Windows) show request-level status codes.
769+ * Look for entries like ` POST /branch/Get ` and ` POST /branch/GetParentBranch ` with ` 401 ` .
770+
771+ Also note:
772+
773+ * ` --output ` values are case-sensitive in current CLI behavior. Use ` Verbose ` , not ` verbose ` .
774+ * During development, TestAuth may be available. See this file for setup details:
775+ ` docs/Authentication.md ` -> ** Development without Auth0 (TestAuth)** .
776+
777+ ### You can see ` SystemAdmin ` in Cosmos, but ` grace access check ` says denied
778+
779+ If ` grace auth whoami ` shows your expected ` GraceUserId ` , but:
780+
781+ * ` grace access check --operation SystemAdmin --resource system --output Json `
782+ returns ` Denied: missing permission SystemAdmin. ` ,
783+
784+ and you can also see a ` SystemAdmin ` assignment document in Cosmos, the most common cause is a ** runtime context mismatch** .
785+
786+ Typical mismatch causes:
787+
788+ * The running server is using a different Orleans ` serviceid ` than the one that wrote the document.
789+ * You inspected a different Cosmos database or container than the running server is using.
790+ * The AccessControl grain loaded state before manual Cosmos edits (stale in-memory state until restart).
791+
792+ Why this happens:
793+
794+ * System-scope role assignments are read from the AccessControl actor state keyed by scope and Orleans identity.
795+ * A document such as ` grace-dev__accesscontrolactor_system ` applies only to the matching Orleans service context.
796+ * If the active server context differs, authorization reads a different actor record.
797+
798+ What to verify first:
799+
800+ PowerShell:
801+
802+ ``` powershell
803+ grace auth whoami --output Json
804+ grace access check --operation SystemAdmin --resource system --output Json
805+ ```
806+
807+ bash / zsh:
808+
809+ ``` bash
810+ grace auth whoami --output Json
811+ grace access check --operation SystemAdmin --resource system --output Json
812+ ```
813+
814+ Then verify server configuration:
815+
816+ * ` GRACE_SERVER_URI ` points to the server you think you are testing.
817+ * The running server's Orleans ` serviceid ` matches the service prefix of the AccessControl actor document.
818+ * The running server's Cosmos database/container match the place where you inspected the document.
819+
820+ Recommended recovery steps:
821+
822+ 1 . Restart ` Grace.Server ` (or your Aspire app host) to clear any stale grain state.
823+ 2 . Re-run the two checks above.
824+ 3 . Re-open Cosmos and confirm the ` system ` AccessControl actor document for the active service context
825+ contains your user principal.
826+ 4 . If needed, use a current ` SystemAdmin ` principal to grant your role again via ` grace access grant-role ` .
827+
828+ ### Headless environments / CI
829+
830+ Use:
701831
702832* M2M auth (client credentials env vars), or
703833* PATs (` GRACE_TOKEN ` ), or
0 commit comments