github: check token scopes even if authorized

This commit is contained in:
Seeker 2021-01-07 17:34:12 -08:00
parent 4256048a9a
commit 4886b3b138

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"]