Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Monkeypatch deprecated omniauth-github behaviour #1012

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
19 changes: 19 additions & 0 deletions config/initializers/omniauth_github.rb
@@ -0,0 +1,19 @@
# frozen_string_literal: true

# The gem in unmaintained but using a deprecated API, this monkeypatches a fix:
# https://github.com/omniauth/omniauth-github/pull/84

module OmniAuthGitHubHeaderAuth
def raw_info
access_token.options[:mode] = :header
@raw_info ||= access_token.get('user').parsed
end

def emails
return [] unless email_access_allowed?
access_token.options[:mode] = :header
@emails ||= access_token.get('user/emails', headers: {'Accept' => 'application/vnd.github.v3'}).parsed
end
end

OmniAuth::Strategies::GitHub.prepend(OmniAuthGitHubHeaderAuth)