Class: Trailblazer::Pro::Trace::Refresh

Inherits:
Activity::Railway
  • Object
show all
Defined in:
lib/trailblazer/pro/trace/refresh.rb

Instance Method Summary collapse

Instance Method Details

#extract_id_token(ctx, parsed_response:) ⇒ Object



24
25
26
# File 'lib/trailblazer/pro/trace/refresh.rb', line 24

def extract_id_token(ctx, parsed_response:, **)
  ctx[:id_token] = parsed_response["id_token"]
end

#extract_refresh_token(ctx, parsed_response:) ⇒ Object



28
29
30
# File 'lib/trailblazer/pro/trace/refresh.rb', line 28

def extract_refresh_token(ctx, parsed_response:, **)
  ctx[:refresh_token] = parsed_response["refresh_token"]
end

#refresh_id_token(ctx, http: Faraday, refresh_token:, firebase_refresh_url:) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/trailblazer/pro/trace/refresh.rb', line 11

def refresh_id_token(ctx, http: Faraday, refresh_token:, firebase_refresh_url:, **)
  ctx[:response] = http.post(
    firebase_refresh_url,
    {
      refresh_token:  refresh_token,
      grant_type:     "refresh_token"
    }.to_json,
    {'Content-Type'=>'application/json', "Accept": "application/json"}
  )

  ctx[:response].status == 200
end