Skip to content
This repository has been archived by the owner on Aug 25, 2020. It is now read-only.

assertion types can provide callbacks #21

Closed
wants to merge 1 commit into from

Conversation

pacovell
Copy link
Contributor

@pacovell pacovell commented Jun 5, 2012

Submitted on request for Issue #20

@bploetz
Copy link
Collaborator

bploetz commented Jun 5, 2012

Can you please also add a note about this feature (with an example) in the README?

@pacovell
Copy link
Contributor Author

pacovell commented Jul 4, 2012

Sorry, behind on this -- here is my example, for @edgar in the other issue:

In application.rb or other initializer with scope to config.oauth:

config.oauth.assertion_handler['facebook.com'] = lambda do |client, assertion, scope|
  Rails.logger.debug("Assertion: #{assertion}")
  graph = Koala::Facebook::GraphAPI.new(assertion)
  begin
    user_data = graph.get_object('me')
    Rails.logger.debug("FB User Data: #{user_data}")
    user = User.find_by_facebook_auth({ :uid => user_data['id']})
  rescue Exception => e
    # fall through
    Rails.logger.debug("Could not find/load Facebook user: #{assertion} / #{e}")
  end
  if user
    Rails.logger.debug('Valid Facebook Assertion')
    user.id.to_s # Requires a string or integer
  else
    Rails.logger.debug('Invalid Facebook Assertion')
    nil
  end
end

If you want this to be called, then your client needs to send its assertion like this (JSON format here):

{
  client_id: <apiClientId>,
  client_secret: <apiClientSecret>,
  grant_type: 'assertion',
  assertion_type: 'facebook.com',
  assertion: <fb access token>
}

@bploetz
Copy link
Collaborator

bploetz commented Jul 10, 2012

@pacovell can you add this example and info to the README? Note that I just did a release, so if you could rebase your branch on top of master that would be great.

@pacovell
Copy link
Contributor Author

OK, rebased, README updated, and made a new pull request.

Thanks,
-Paul

On Tue, Jul 10, 2012 at 3:55 PM, Brian Ploetz <
[email protected]

wrote:

@pacovell can you add this example and info to the README? Note that I
just did a release, so if you could rebase your branch on top of master
that would be great.


Reply to this email directly or view it on GitHub:
#21 (comment)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants