Module: Ecoportal::API::Common::GraphQL::AuthService::InstanceMethods
- Included in:
- Ecoportal::API::Common::GraphQL::AuthService
- Defined in:
- lib/ecoportal/api/common/graphql/auth_service.rb
Instance Method Summary collapse
- #session_token(host: server, auto_renew: true) ⇒ Object
- #session_token_renewed(host: server, refresh_token: nil) ⇒ Object
Instance Method Details
#session_token(host: server, auto_renew: true) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/ecoportal/api/common/graphql/auth_service.rb', line 10 def session_token(host: server, auto_renew: true) session_token_data(host: host).then do |body| next unless body if auto_renew && token_renew?(body['expires_in']) session_token_renewed( host: host, refresh_token: body['refresh_token'] ) else body['access_token'] end end end |
#session_token_renewed(host: server, refresh_token: nil) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/ecoportal/api/common/graphql/auth_service.rb', line 25 def session_token_renewed(host: server, refresh_token: nil) unless refresh_token return unless (body = session_token_data(host: host)) return unless (refresh_token = body['resfresh_token']) end session_refresh_token_data( host: host, refresh_token: refresh_token ).then do |bdy| bdy['access_token'] if bdy end end |