Method: Auth::ClientCredentials::Service#get_token
- Defined in:
- lib/lighthouse/auth/client_credentials/service.rb
#get_token(auth_params = {}) ⇒ String
Request an access token
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/lighthouse/auth/client_credentials/service.rb', line 40 def get_token(auth_params = {}) if @service_name.nil? res = get_new_token(auth_params) return res.body['access_token'] end access_token = @tracker.get_access_token(@service_name) if access_token.nil? uuid = SecureRandom.uuid log_info(message: 'Access token expired. Fetching new token', service_name: @service_name, uuid:) res = get_new_token(auth_params) access_token = res.body['access_token'] ttl = res.body['expires_in'] @tracker.set_access_token(@service_name, access_token, ttl) log_info(message: "New access token deposited in Redis store with TTL: #{ttl}", service_name: @service_name, uuid:) end access_token end |