Skip to content

Official TeamSnap strategy for OmniAuth

License

Notifications You must be signed in to change notification settings

teamsnap/omniauth-teamsnap

Repository files navigation

OmniAuth TeamSnap

Gem Version License

This is the official OmniAuth strategy for authenticating to TeamSnap. To use it, you'll need to sign up for an OAuth2 Application Id and Secret on Cogsworth.

Basic Usage

use OmniAuth::Builder do
  provider :teamsnap, ENV['TEAMSNAP_KEY'], ENV['TEAMSNAP_SECRET']
end

Scopes

TeamSnap API v3 lets you set scopes to provide granular access to different types of data:

use OmniAuth::Builder do
  provider :teamsnap, ENV['TEAMSNAP_KEY'], ENV['TEAMSNAP_SECRET'], scope: "read write"
end

Authentication Hash

An example auth hash available in request.env['omniauth.auth']:

{
  :provider => "teamsnap",
  :uid => "123456",
  :info => {
    :email => "player@example.com",
    :first_name => "John",
    :last_name => "Player",
  },
  :credentials => {
    :token => "a1b2c3d4...", # The OAuth 2.0 access token
  },
  :extra = {}
}

Testing

docker build . -t omniauth-teamsnap:test -f Test.dockerfile
docker run -t omniauth-teamsnap:test
docker image rm omniauth-teamsnap:test --force