Merge pull request #10258 from SeekingMeaning/github-scopes

github: check token scopes even if authorized
This commit is contained in:
Mike McQuaid 2021-01-08 09:42:56 +00:00 committed by GitHub
commit 060c59772f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -141,9 +141,8 @@ module GitHub
def api_credentials_error_message(response_headers, needed_scopes)
return if response_headers.empty?
unauthorized = (response_headers["http/1.1"] == "401 Unauthorized")
scopes = response_headers["x-accepted-oauth-scopes"].to_s.split(", ")
return unless unauthorized && scopes.blank?
return if scopes.present?
needed_human_scopes = needed_scopes.join(", ")
credentials_scopes = response_headers["x-oauth-scopes"]