Skip to content

Instantly share code, notes, and snippets.

@svensson-david
Last active August 29, 2015 13:57
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save svensson-david/9481536 to your computer and use it in GitHub Desktop.
Save svensson-david/9481536 to your computer and use it in GitHub Desktop.
Oauth strategy for Tictail authentication
# Oauth strategy for Tictail authentication
# You will need additional code to handle the logins
# If using Devise follow this guide - https://github.com/plataformatec/devise/wiki/OmniAuth:-Overview
require 'omniauth-oauth2'
module OmniAuth
module Strategies
class TictailOauth2 < OmniAuth::Strategies::OAuth2
# Give your strategy a name.
option :name, "tictail_oauth2"
# This is where you pass the options you would pass when
# initializing your consumer from the OAuth gem.
option :client_options, {:site => "https://tictail.com/oauth/token"}
# These are called after authentication has succeeded. If
# possible, you should try to set the UID without making
# additional calls (if the user id is returned with the token
# or as a URI parameter). This may not be possible with all
# providers.
uid {
# Using store url as uid
access_token.params['store']['url']
}
info do
{
:name => access_token.params['store']['name'],
:email => access_token.params['store']['storekeeper_email']
}
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment