Module: Tenzing::OauthExtract

Extended by:
ActiveSupport::Concern
Defined in:
lib/tenzing/oauth_extract.rb

Instance Method Summary collapse

Instance Method Details

#get_oauth_dataObject



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/tenzing/oauth_extract.rb', line 14

def get_oauth_data
  return nil unless @oauth.present?
  @oauth_data = {
      user: {
          email:  @oauth.info['email'],
          name:   @oauth.info['name'],
          image:  @oauth.info['image'],
      },
      auth: {
          provider:     @oauth.provider,
          uid:          @oauth.uid,
          username:     @oauth.info['nickname'],
          auth_token:   @oauth.credentials['token'],
          auth_secret:  @oauth.credentials['secret'],
          expires_at:   parse_expiration_date(@oauth),
      }
  }
  raise 'Unable to get OAuth2 data' if @oauth_data.empty?
end

#parse_requestObject



10
11
12
# File 'lib/tenzing/oauth_extract.rb', line 10

def parse_request
  @oauth = request.env['omniauth.auth']
end