Module: FidorApi::Client::Authentication
- Included in:
- FidorApi::Client
- Defined in:
- lib/fidor_api/client/authentication.rb
Instance Attribute Summary collapse
-
#token ⇒ Object
Returns the value of attribute token.
Instance Method Summary collapse
-
#authorize_complete(redirect_uri:, code:) ⇒ Object
oAuth2 - Authorization Code Grant Flow - Complete.
-
#authorize_start(redirect_uri:, state: SecureRandom.hex(8)) ⇒ Object
oAuth2 - Authorization Code Grant Flow - Start.
-
#client_login ⇒ Object
oAuth2 - Client Credentials Flow.
-
#login(username:, password:, grant_type: 'password') ⇒ Object
oAuth2 - Resource Owner Password Grant Flow.
Instance Attribute Details
#token ⇒ Object
Returns the value of attribute token.
4 5 6 |
# File 'lib/fidor_api/client/authentication.rb', line 4 def token @token end |
Instance Method Details
#authorize_complete(redirect_uri:, code:) ⇒ Object
oAuth2 - Authorization Code Grant Flow - Complete
36 37 38 39 40 41 42 43 |
# File 'lib/fidor_api/client/authentication.rb', line 36 def (redirect_uri:, code:) self.token = oauth_token( grant_type: 'authorization_code', client_id: config.client_id, redirect_uri: redirect_uri, code: code ) end |
#authorize_start(redirect_uri:, state: SecureRandom.hex(8)) ⇒ Object
oAuth2 - Authorization Code Grant Flow - Start
25 26 27 28 29 30 31 32 33 |
# File 'lib/fidor_api/client/authentication.rb', line 25 def (redirect_uri:, state: SecureRandom.hex(8)) check_flow_support! :authorization_code "#{config.environment.auth_redirect_host}/oauth/authorize" \ + "?client_id=#{config.client_id}" \ + "&redirect_uri=#{CGI.escape(redirect_uri)}" \ + "&state=#{state}" \ + '&response_type=code' end |
#client_login ⇒ Object
oAuth2 - Client Credentials Flow
18 19 20 21 22 |
# File 'lib/fidor_api/client/authentication.rb', line 18 def client_login check_flow_support! :client_credentials self.token = oauth_token(grant_type: 'client_credentials') end |
#login(username:, password:, grant_type: 'password') ⇒ Object
oAuth2 - Resource Owner Password Grant Flow
7 8 9 10 11 12 13 14 15 |
# File 'lib/fidor_api/client/authentication.rb', line 7 def login(username:, password:, grant_type: 'password') check_flow_support! :resource_owner_password_credentials self.token = oauth_token( grant_type: grant_type, username: username, password: password ) end |