Class: OmniAuth::Strategies::Zalo2
- Inherits:
-
OAuth2
- Object
- OAuth2
- OmniAuth::Strategies::Zalo2
- Defined in:
- lib/omniauth/strategies/zalo2.rb
Instance Method Summary collapse
- #authorize_params ⇒ Object
- #build_access_token ⇒ Object
- #callback_url ⇒ Object
- #get_tokens_params ⇒ Object
- #raw_info ⇒ Object
Instance Method Details
#authorize_params ⇒ Object
38 39 40 41 42 |
# File 'lib/omniauth/strategies/zalo2.rb', line 38 def super.tap do |params| params[:app_id] = [:client_id] end end |
#build_access_token ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/omniauth/strategies/zalo2.rb', line 48 def build_access_token # ref https://gitlab.com/oauth-xx/oauth2/-/blob/main/lib/oauth2/client.rb#L118 response = client.request( client.[:token_method], client.token_url, { headers: { "secret_key" => "#{[:client_secret]}"}, body: get_tokens_params, parse: :json } ).parsed # ref https://gitlab.com/oauth-xx/oauth2/-/blob/main/lib/oauth2/access_token.rb#L19 ::OAuth2::AccessToken.from_hash(client, response) end |
#callback_url ⇒ Object
44 45 46 |
# File 'lib/omniauth/strategies/zalo2.rb', line 44 def callback_url [:callback_url] || (full_host + script_name + callback_path) end |
#get_tokens_params ⇒ Object
64 65 66 67 68 69 70 71 |
# File 'lib/omniauth/strategies/zalo2.rb', line 64 def get_tokens_params {}.tap do |params| params[:code] = request.params['code'] params[:app_id] = [:client_id] params[:grant_type] = 'authorization_code' params[:code_verifier] = pkce_token_params[:code_verifier] end end |
#raw_info ⇒ Object
19 20 21 22 23 |
# File 'lib/omniauth/strategies/zalo2.rb', line 19 def raw_info @raw_info ||= access_token.get( "https://graph.zalo.me/v2.0/me?access_token=#{access_token.token}&fields=id,name,picture,phone" ).parsed || {} end |