Troubleshooting Builds "Unauthorized" due to contexts

Overview

If you are using a context in your workflow, you may encounter the following message. 

Screenshot 2023-09-18 at 12.34.48 PM.png

Solutions

If your builds are failing as "Unauthorized" and you are utilizing contexts, please try the following troubleshooting steps:

  1. Check GitHub App authorization: If you're using a GitHub App-integrated pipeline (verify in Project Settings > Project setup - you'll see a badge above your pipeline definition):
    1. Check the navbar at the top of any CircleCI page:
      1. If you see "Your GitHub identity is not verified": Click Authorize.
      2. If you don't see this message: Go to https://github.com/settings/apps/authorizations, click Revoke next to "CircleCI App", then return to CircleCI and click Authorize on the navbar button that appears.
    2. If either action produces an error: Submit a support request through this form and we'll assist you as quickly as possible. You can skip the remaining steps.
    3. If no error occurs: The authorization issue should be resolved. If builds still fail, continue to the next steps below.
  2. Authorize GitLab Account: If you're using a GitLab-integrated pipeline, ensure your account is authorized by navigating to Project Settings > Pipelines > Add Pipeline > Authorize.
  3. Restricted Contexts: If you are using a Restricted Context, confirm the blocked user is a part of the security group (defined by GitHub teams), users that are not a part of the GitHub team will not have access to the context
  4. Stale Permissions: If your permission level recently changed, please have an organization admin refresh your user permissions. Additionally, the user in question should also refresh their permissions. A user can refresh their permissions by navigating to their user settings page and click "Refresh Permissions." 
  5. Nested Teams: If the context you are attempting to use is part of a nested team, you will need to add the nested team as a security group
  6. Account renames: If you recently renamed your GitHub username and are suddenly experiencing permission issues please contact Support
  7. Browser extensions: Try to disable browser extensions or log in from a different browser and/or device. If you are still blocked, please submit a HAR file to Support
  8. Invalid/Expired OAuth token: Proceed to a full re-authentication
    1. Sign out of your CircleCI account
    2. Revoke CircleCI's access in Bitbucket or GitHub
    3. Clear your browser's cache and cookies
    4. Sign back into your CircleCI account
    5. Refresh permissions at https://app.circleci.com/settings/user
  9. Recent change to Context Restrictions: If you've recently adjusted the permissions of a context, changes may not be available immediately due to caching. You will need an organization admin to refresh permissions at https://app.circleci.com/settings/user (more info)
  10. Project Restrictions: If your team utilizes project restrictions on Contexts, you may be trying to use the Context in a project that it is not authorized to be used in.
  11. Context Expression Restrictions: If your organization has enabled Context Expression Restrictions, you may need to verify that you are not triggering any of the restrictions.
  12. You may have another CircleCI account setup that uses the CircleCI OAuth App Integration. To confirm that this is the root cause, please navigate to your user settings page > account integrations. If you see that your GitHub account is connected, this is not the case. If you do not see your GItHub Account listed, you may have two separate CircleCI user accounts setup. You can find instructions on how to resolve this issue here.

Please note that you can leverage the CircleCI v2 API to find the user id of a user who triggered a workflow. You can use the Get a workflow endpoint. The value assigned to started_by key in the response corresponds to the user ID of the user who triggered the build. 

Please refer to another article if the issue is not resolved by the above solution.

 

Additional Resources

Was this article helpful?
4 out of 30 found this helpful

Comments

0 comments

Article is closed for comments.