microsoft / microsoft/winget-create

Unhandled exception. Octokit.ForbiddenException: Resource protected by organization SAML enforcement. You must grant your OAuth token access to this organization.

Open
#628 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Issue-Bug
Dominant language
C#
Stars
651
Forks
114
Avg merge
7h 52m
Merged PRs (30d)
3

Description

Brief description of your issue

Today when I want to use WinGetCreate to create a manifest, I was told that:

Token was invalid. Please generate a new GitHub token and try again.

So I ran wingetcreate token --store and signed into GitHub in the browser. It seemed succeeded, however, after that I got the following error message when running any command, even including wingetcreate token --clear and wingetcreate token --store:

Unhandled exception. Octokit.ForbiddenException: Resource protected by organization SAML enforcement. You must grant your OAuth token access to this organization.
   at Octokit.Connection.HandleErrors(IResponse response) in /_/Octokit/Http/Connection.cs:line 785
   at Octokit.Connection.RunRequest(IRequest request, CancellationToken cancellationToken, Func`2 preprocessResponseBody) in /_/Octokit/Http/Connection.cs:line 766
   at Octokit.Connection.Run[T](IRequest request, CancellationToken cancellationToken, Func`2 preprocessResponseBody) in /_/Octokit/Http/Connection.cs:line 751
   at Octokit.ApiConnection.Get[T](Uri uri, IDictionary`2 parameters)
   at Microsoft.WingetCreateCore.Common.GitHub.CheckAccess()
   at Microsoft.WingetCreateCLI.Commands.BaseCommand.CheckGitHubTokenAndSetClient()
   at Microsoft.WingetCreateCLI.Commands.BaseCommand.LoadGitHubClient(Boolean requireToken)
   at Microsoft.WingetCreateCLI.Program.Main(String[] args)
   at Microsoft.WingetCreateCLI.Program.<Main>(String[] args)
{"message":"Resource protected by organization SAML enforcement. You must grant your OAuth token access to this organization.","documentation_url":"https://docs.github.com/articles/authenticating-to-a-github-organization-with-saml-single-sign-on/","status":"403"}

I don't know which step during the login was wrong, but now I could not even clear the access token. I remember there was a step to authorize my organization and I ignored it, but I don't know how to redo it now. I even tried to reinstall WinGetCreate but the token seemed not cleared, either.

If there is any other way to clear the token or sign in again please tell me, thanks.

Steps to reproduce

As above.

Expected behavior

Successfully stored the access token and access the GitHub repositories.

Actual behavior

As shown in the description.

Environment
> wingetcreate info
Windows Package Manager Manifest Creator v1.10.3.0
Copyright (c) Microsoft Corporation. All rights reserved.

Operating System: Microsoft Windows NT 10.0.26200.0
System Architecture: X64

Winget-Create Directories  Path                                                                                         
------------------------------------------------------------------------------------------------------------------------------------------
Logs                       %LOCALAPPDATA%\Packages\Microsoft.WindowsPackageManagerManifestCreator_8wekyb3d8bbwe\LocalState\DiagOutputDir
User settings              %LOCALAPPDATA%\Packages\Microsoft.WindowsPackageManagerManifestCreator_8wekyb3d8bbwe\LocalState\settings.json
Installer cache            %TEMP%\wingetcreate                                                                          

Links
------------------------------------------------------------------
Privacy Statement    https://aka.ms/winget-create-privacy
License Agreement    https://aka.ms/winget-create-license
Third Party Notices  https://aka.ms/winget-create-3rdPartyNotice
Homepage             https://aka.ms/winget-create

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with Microsoft.WingetCreateCore.Common.GitHub.CheckAccess and Microsoft.WingetCreateCLI.Commands.BaseCommand.LoadGitHubClient, using the token command flow described in the report. Check the user settings path shown by wingetcreate info and reproduce the SAML failure; done means token clearing and sign-in can be completed without the unhandled exception.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp, github
Domain
authentication, cli
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.