Module: Sorcery::Protocols::Oauth2
- Included in:
- Sorcery::Providers::Auth0, Sorcery::Providers::Battlenet, Sorcery::Providers::Discord, Sorcery::Providers::Facebook, Sorcery::Providers::Github, Sorcery::Providers::Google, Sorcery::Providers::Heroku, Sorcery::Providers::Instagram, Sorcery::Providers::Line, Sorcery::Providers::Linkedin, Sorcery::Providers::Liveid, Sorcery::Providers::Microsoft, Sorcery::Providers::Paypal, Sorcery::Providers::Salesforce, Sorcery::Providers::Slack, Sorcery::Providers::Vk, Sorcery::Providers::Wechat
- Defined in:
- lib/sorcery/protocols/oauth2.rb
Instance Method Summary collapse
- #authorize_url(options = {}) ⇒ Object
- #build_client(options = {}) ⇒ Object
- #get_access_token(args, options = {}) ⇒ Object
- #oauth_version ⇒ Object
Instance Method Details
#authorize_url(options = {}) ⇒ Object
10 11 12 13 14 15 16 17 18 |
# File 'lib/sorcery/protocols/oauth2.rb', line 10 def ( = {}) client = build_client() client.auth_code.( redirect_uri: @callback_url, scope: @scope, display: @display, state: @state ) end |
#build_client(options = {}) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/sorcery/protocols/oauth2.rb', line 32 def build_client( = {}) defaults = { site: @site, auth_scheme: :request_body, ssl: { ca_file: Sorcery::Controller::Config.ca_file } } ::OAuth2::Client.new( @key, @secret, defaults.merge!() ) end |
#get_access_token(args, options = {}) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/sorcery/protocols/oauth2.rb', line 20 def get_access_token(args, = {}) client = build_client() client.auth_code.get_token( args[:code], { redirect_uri: @callback_url, parse: .delete(:parse) }, ) end |
#oauth_version ⇒ Object
6 7 8 |
# File 'lib/sorcery/protocols/oauth2.rb', line 6 def oauth_version '2.0' end |