class SBF::Client::Facebook::UserEndpoint
Public Instance Methods
login!(authorization_code, redirect_uri)
click to toggle source
Logs in a user, using a Facebook
Oauth authorization code & redirect uri. Configures the client library to use user credentials for subsequent requests. Returns the SBF
access token for the user that should be held onto to configure the client library in future requests that are outside of this scope.
@param authorization_code [string] @param redirect_uri [string] @return [string]
# File lib/stbaldricks/endpoints/facebook/user.rb, line 15 def login!(authorization_code, redirect_uri) response = SBF::Client::Api::Request.post_request( "/#{SBF::Client::Api::VERSION}/security/facebook/login", authorization_code: authorization_code, redirect_uri: redirect_uri ) parsed_response = JSON.parse(response.body).symbolize! if ok?(response) SBF::Client::Configuration.user_token = parsed_response[:token] data = parsed_response.merge(user: target_class.new(parsed_response[:user])) SBF::Client::LOG.info { "SBF::Client - Facebook User Login with Identifier: #{parsed_response[:user][:identifier]}" } else SBF::Client::Configuration.user_token = nil error = SBF::Client::ErrorEntity.new(parsed_response) end SBF::Client::Api::Response.new(http_code: response.code, data: data, error: error) end