omniauth-beam 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a93616647610037f3519d2324275b7bb6165aeb4
4
- data.tar.gz: 5dd4b43b19ab16d033cee38620ad2738ce8f6300
3
+ metadata.gz: 04f2317efcd80fed535e8e03b2c60e18f224b40b
4
+ data.tar.gz: fa48ba501a105646cb80cadaf04d9e92d43ffd65
5
5
  SHA512:
6
- metadata.gz: 7e46738397034a9a39fd00ebdee8fa63130fe504a3287bef1e83f3af4f12b979a360373fc8d06917b63a3b73e1ab8a0f0da0c5f04448718b11b1305c7537717f
7
- data.tar.gz: e54e154171794259a48498abcf2675c9bc73e0d9b3219d757c25e0647abb63858d2e8cb44c2e8792fc058802a9646676167264e6d876a2ac5b7c53ef23f6fcf2
6
+ metadata.gz: 29f3dff16e1948ecc871d22a6ab77142cecd1b34f13a586042547f5bb5a5799ecd5c8c16c12e759fcbe2c0685f0549bdbd0d61fe74a346026e298780495d34bb
7
+ data.tar.gz: f147f73c27693c91dfd86d5b4e0360c8fcb0bfc3a46c8818801a92f5352cf4d67eadf0753a514bb8f08c90883ba481d38714e0fd8732f278af6d91e4ba0a1d4b
data/README.md CHANGED
@@ -1,2 +1,77 @@
1
- # omniauth-beam
1
+ [![Gem Version](https://badge.fury.io/rb/omniauth-beam.svg)](https://badge.fury.io/rb/omniauth-beam)
2
+
3
+ # OmniAuth::Beam
2
4
  OmniAuth strategy for Beam.pro
5
+
6
+ ## Installation
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'omniauth-beam'
10
+
11
+ Then run `bundle install`
12
+
13
+ Or install it yourself with `gem install omniauth-beam`
14
+
15
+ ### Using Directly
16
+ ```ruby
17
+ Rails.application.config.middleware.use OmniAuth::Builder do
18
+ provider :beam, ENV['BEAM_CLIENT_ID'], ENV['BEAM_SECRET_ID']
19
+ end
20
+ ```
21
+
22
+ ### Using With Devise
23
+ Add to `config/initializers/devise.rb`
24
+ ```ruby
25
+ config.omniauth :beam, ENV['BEAM_CLIENT_ID'], ENV['BEAM_SECRET_ID']
26
+ ```
27
+
28
+ And apply it to your Devise user model:
29
+ ```ruby
30
+ class User < ApplicationRecord
31
+ devise :database_authenticatable, :registerable, :recoverable, :rememberable,
32
+ :trackable, :validatable, :omniauthable,
33
+ omniauth_providers: %i(beam)
34
+
35
+ def self.from_omniauth(auth)
36
+ user = where(provider: auth.provider, uid: auth.uid).first_or_create do |u|
37
+ u.password = Devise.friendly_token[0, 20]
38
+ u.provider = auth.provider
39
+ u.uid = auth.uid
40
+ end
41
+ user.update avatar_url: auth.info.image,
42
+ email: auth.info.email,
43
+ name: auth.info.name
44
+ user
45
+ end
46
+ end
47
+ ```
48
+
49
+ ## Default Scope
50
+
51
+ The default scope is set to _user:details:self_, making this hash available in `request.env['omniauth.auth']`:
52
+ ```ruby
53
+ {
54
+ provider: 'beam',
55
+ uid: 123456789,
56
+ info: {
57
+ name: 'JohnDoe',
58
+ email: 'johndoe@example.com',
59
+ description: 'My channel.',
60
+ image: 'https://uploads.beam.pro/avatar/12345678-1234.jpg',
61
+ social: {
62
+ discord: 'johndoe#12345',
63
+ facebook: 'https://facebook.com/John.Doe'
64
+ player: 'https://player.me/johndoe',
65
+ twitter: 'https://twitter.com/johndoe',
66
+ youtube: 'https://youtube.com/user/johndoe'
67
+ },
68
+ urls: { Beam: 'https://beam.pro/johndoe' }
69
+ },
70
+ credentials: {
71
+ token: 'asdfghjklasdfghjklasdfghjkl',
72
+ refresh_token: 'qwertyuiopqwertyuiopqwertyuiop',
73
+ expires_at: 1477577799,
74
+ expires: true
75
+ }
76
+ }
77
+ ```
@@ -1,5 +1,5 @@
1
1
  module OmniAuth
2
2
  module Beam
3
- VERSION = '0.1.0'.freeze
3
+ VERSION = '0.1.1'.freeze
4
4
  end
5
5
  end
@@ -7,6 +7,7 @@ module OmniAuth
7
7
  BLANK_PARAMS = [nil, ''].freeze
8
8
  DEFAULT_SCOPE = 'user:details:self'.freeze
9
9
  RAW_INFO_URL = '/api/v1/users/current'.freeze
10
+ SOCIAL_KEYS = %w(facebook discord player twitter youtube).freeze
10
11
 
11
12
  option :name, 'beam'
12
13
 
@@ -29,7 +30,8 @@ module OmniAuth
29
30
  email: raw_info['email'],
30
31
  description: raw_info['bio'],
31
32
  image: raw_info['avatarUrl'],
32
- urls: { Beam: "http://beam.pro/#{raw_info['name']}" }
33
+ social: social_info,
34
+ urls: urls_info
33
35
  }
34
36
  end
35
37
 
@@ -63,6 +65,20 @@ module OmniAuth
63
65
  def raw_info
64
66
  @raw_info ||= access_token.get(RAW_INFO_URL).parsed
65
67
  end
68
+
69
+ def social_info
70
+ raw_social = raw_info['social']
71
+ SOCIAL_KEYS.each_with_object({}) do |key, hsh|
72
+ hsh[key.to_sym] = raw_social[key] if raw_social.key? key
73
+ hsh
74
+ end
75
+ end
76
+
77
+ def urls_info
78
+ {
79
+ Beam: "http://beam.pro/#{raw_info['channel']['token']}"
80
+ }
81
+ end
66
82
  end # Beam
67
83
  end # Strategies
68
84
  end # OmniAuth
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: omniauth-beam
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Christopher Nicholson-Sauls "charmquark"