Merge pull request #10490 from nandahkrishna/fix-api-credentials-error
utils/github: fix false positive API credential error
This commit is contained in:
commit
8eeb838440
@ -150,13 +150,11 @@ module GitHub
|
|||||||
return if response_headers.empty?
|
return if response_headers.empty?
|
||||||
|
|
||||||
scopes = response_headers["x-accepted-oauth-scopes"].to_s.split(", ")
|
scopes = response_headers["x-accepted-oauth-scopes"].to_s.split(", ")
|
||||||
return if scopes.present?
|
needed_scopes = Set.new(scopes || needed_scopes)
|
||||||
|
|
||||||
needed_human_scopes = needed_scopes.join(", ")
|
|
||||||
credentials_scopes = response_headers["x-oauth-scopes"]
|
credentials_scopes = response_headers["x-oauth-scopes"]
|
||||||
return if needed_human_scopes.blank? && credentials_scopes.blank?
|
return if needed_scopes.subset?(Set.new(credentials_scopes.to_s.split(", ")))
|
||||||
|
|
||||||
needed_human_scopes = "none" if needed_human_scopes.blank?
|
needed_scopes = needed_scopes.to_a.join(", ").presence || "none"
|
||||||
credentials_scopes = "none" if credentials_scopes.blank?
|
credentials_scopes = "none" if credentials_scopes.blank?
|
||||||
|
|
||||||
what = case api_credentials_type
|
what = case api_credentials_type
|
||||||
@ -168,7 +166,7 @@ module GitHub
|
|||||||
|
|
||||||
@api_credentials_error_message ||= onoe <<~EOS
|
@api_credentials_error_message ||= onoe <<~EOS
|
||||||
Your #{what} credentials do not have sufficient scope!
|
Your #{what} credentials do not have sufficient scope!
|
||||||
Scopes required: #{needed_human_scopes}
|
Scopes required: #{needed_scopes}
|
||||||
Scopes present: #{credentials_scopes}
|
Scopes present: #{credentials_scopes}
|
||||||
Create a personal access token:
|
Create a personal access token:
|
||||||
#{ALL_SCOPES_URL}
|
#{ALL_SCOPES_URL}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user