class Lyft::Client::Api::Oauth
Client
for making authentication related requests to the lyft api
Public Instance Methods
retrieve_access_token(authorization_code: nil, scope: Scope::PUBLIC)
click to toggle source
Retrieves access token from the server.
@example Get public access token.
resp = client.authentication.retrieve_access_token resp.success?
@example Get access token from authorization_code.
resp = client.authentication.retrieve_access_token authorization_code: 'auth_code' resp.success?
@param [String] authorization_code @param [String] scope @return [HTTParty::Response]
# File lib/lyft/client/api/oauth.rb, line 24 def retrieve_access_token(authorization_code: nil, scope: Scope::PUBLIC) body = build_auth_body(authorization_code, scope) resp = connection.post '/oauth/token', body handle_response(resp) end
Private Instance Methods
build_auth_body(authorization_code, scope)
click to toggle source
# File lib/lyft/client/api/oauth.rb, line 32 def build_auth_body(authorization_code, scope) body = {} body[:grant_type] = grant_type(authorization_code) if authorization_code.present? body[:code] = authorization_code else body[:scope] = scope end body end
grant_type(authorization_code)
click to toggle source
# File lib/lyft/client/api/oauth.rb, line 44 def grant_type(authorization_code) return GrantType::AUTHORIZATION_CODE if authorization_code GrantType::CLIENT_CREDENTIALS end