Module: Lyft::Api::Oauth

Included in:
Client
Defined in:
lib/lyft/api/oauth/public_token.rb

Instance Method Summary collapse

Instance Method Details

#public_token(renew = false) ⇒ Object

TODO:

Use same token until expires

Retrieve public oauth token.



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/lyft/api/oauth/public_token.rb', line 9

def public_token(renew = false)
  # return @public_token unless @public_token.nil? && !renew

  uri = Lyft.endpoint('/oauth/token')
  options = {
    body: {
      grant_type: 'client_credentials',
      scope: 'public'
    },
    basic_auth: {
      username: @client_id,
      password: @client_secret
    }
  }

  response = HTTParty.post(uri, options).deep_symbolize_keys!
  @public_token = Struct.new(*response.keys).new(*response.values)
end