OmniAuth strategy for FamilySearch OAuth2 API.
There is also a companion strategy for the Identity v2 API (OAuth 1.0a).
Note: FamilySearch requires web apps to use the OAuth 2 API.
Add this line to your application's Gemfile:
gem 'omniauth-familysearch', git: 'https://github.com/paulwhiting/omniauth-familysearch.git'
And then execute:
$ bundle
You may need to fix the version of omniauth used if you get errors at runtime
gem 'omniauth-oauth2', '~> 1.3.1'
# In config/initializers/omniauth.rb -- tested with rails 5
# Choose one of these blocks to add to your initializer file
# For production
Rails.application.config.middleware.use OmniAuth::Builder do
provider :familysearch, Rails.application.secrets.familysearch_key, '',
end
# For the beta server
Rails.application.config.middleware.use OmniAuth::Builder do
provider :familysearch, Rails.application.secrets.familysearch_key, '',
:client_options => {
site: 'https://identbeta.familysearch.org', # for the beta server -- the oauth url
api_site: 'https://beta.familysearch.org' # for the beta server -- the api url
}
end
# To use the sandbox/integration API
Rails.application.config.middleware.use OmniAuth::Builder do
provider :familysearch, Rails.application.secrets.familysearch_key, '',
:client_options => { :site => 'https://integration.familysearch.org' }
end
Here's an example Auth Hash available in request.env['omniauth.auth']
:
{
"provider" => "familysearch",
"uid" => "MMMM-QY4Y",
"info" => {
"name" => "John Doe",
"email" => "[email protected]"
},
"credentials" => {
"token" => "56421fc9ac",
"secret" => "6f532ad1bb"
},
"extra" => {
"access_token" => "56421fc9ac",
"raw_info" => {
"users" => [
{
"id" => "MMMM-QY4Y",
"contactName" => "John Doe",
"email" => "[email protected]",
"links" => {
"self" => {
"href" => "https://sandbox.familysearch.org/platform/users/current?access_token=abc123"
}
}
}
]
}
}
}
https://familysearch.org/developers/docs/guides/oauth2
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Added some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request