class

Devise::OmniAuth::GitHub

Inherits Devise::OmniAuth::Strategy < Reference < Object

github strategy — 1:1 with omniauth-github 2.0.1: client endpoints, no default scope, uid = raw_info['id'], email from /user/emails when the configured scope allows it (primary+verified) else raw_info email, extra carries all_emails + token scope (null when absent).

Constants

DEFAULT_AUTHORIZE_URL = "https://github.com/login/oauth/authorize"
DEFAULT_SITE = "https://api.github.com"
DEFAULT_TOKEN_URL = "https://github.com/login/oauth/access_token"
EMAIL_SCOPES = ["user", "user:email"] of ::String

Constructors

new(client_id : String, client_secret : String, scope : String | Nil = nil)
Source

Instance methods

auth_hash(token : Token, raw_info : Hash(String, JSON::Any), all_emails : Array(Hash(String, JSON::Any))) : AuthHash

The AuthHash assembled from a token response + raw_info + emails (oracle: gh_hash_user, gh_hash_no_email_scope, gh_hash_uid): uid = raw_info['id'], email via primary_email when the scope allows else raw_info['email'], extra = raw_info + all_emails + token scope (null when absent).

Source
authenticate(code : String, redirect_uri : String) : AuthHash

Full callback phase: code → token → user (+emails) → AuthHash.

Source
authorize_url(redirect_uri : String, scope : String | Nil = nil, state : String | Nil = nil) : String

authorize_params 1:1: response_type=code, scope only when configured (GitHub has no client-side default), 48-hex state.

Source
authorize_url
Source
authorize_url=(authorize_url : String)
Source
client_id
Source
client_secret
Source
email_access_allowed?
Source
emails(access_token : String) : Array(Hash(String, JSON::Any))

GET /user/emails — only meaningful with email scope (the gem returns [] without even calling the endpoint).

Source
primary_email(all_emails : Array(Hash(String, JSON::Any))) : String | Nil

The first primary+verified entry of /user/emails, else nil.

Source
scope

The configured (strategy options) scope — drives the email access decision, exactly like the gem's options['scope'].

Source
scope=(scope : String | Nil)

The configured (strategy options) scope — drives the email access decision, exactly like the gem's options['scope'].

Source
site
Source
site=(site : String)
Source
token(code : String, redirect_uri : String) : Token

POST token_url (authorization_code grant). GitHub answers JSON when asked to (Accept header), like the oauth2 gem's default.

Source
token_url
Source
token_url=(token_url : String)
Source
user(access_token : String) : Hash(String, JSON::Any)

GET /user with the bearer token (header mode, raw_info).

Source