omniauth-intercom 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 +4 -4
- data/CHANGELOG.md +6 -0
- data/README.md +51 -0
- data/lib/omniauth/intercom/version.rb +1 -1
- data/lib/omniauth/strategies/intercom.rb +10 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e4b9a3e6d43aab0e16d421199e711811a99af80b
|
4
|
+
data.tar.gz: 851ce2cc70ec3088218d8057952166421e2275dc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 291e5181db1f500963bbb928c3bd555a63c1cbf56fd9cd6896a52a16f53d1284a4949e8c746defd9c666669006b6e1022530187314760087cc83f3168c9b03d1
|
7
|
+
data.tar.gz: 2c6831280024a72c47d917e79735934450da7707ff5a0e89a729a50482cb2a176868564db7aeb759f8de98ec4791c574f984fe738f35102c94a8d6d7552ffcef
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -27,6 +27,7 @@ Rails.application.config.middleware.use OmniAuth::Builder do
|
|
27
27
|
end
|
28
28
|
```
|
29
29
|
To start the authentication process with Intercom you simply need to access `/auth/intercom` route.
|
30
|
+
You can start the authentication process directly with the signup page by accessing `/auth/intercom?signup=1`
|
30
31
|
|
31
32
|
**Important** You need the `read_admins` permissions to use this middleware.
|
32
33
|
**Important** Your `redirect_url` should be `/auth/intercom/callback`
|
@@ -64,3 +65,53 @@ Here's an example *Auth Hash* available in `request.env['omniauth.auth']`:
|
|
64
65
|
}
|
65
66
|
}
|
66
67
|
```
|
68
|
+
|
69
|
+
### Intercom Button / Popup authentication
|
70
|
+
|
71
|
+
To use `Intercom Button` to display authentication in a popup it is simple :
|
72
|
+
|
73
|
+
- Add the following code in the html file in which you want to start to authenticate with Intercom ( `/views/home/index.html.erb` if you want to authenticate with Intercom in `home#index`)
|
74
|
+
|
75
|
+
```html
|
76
|
+
<a href="javascript:void(0)" class="intercom-oauth-cta">
|
77
|
+
<img src="https://static.intercomassets.com/assets/oauth/primary-7edb2ebce84c088063f4b86049747c3a.png" srcset="https://static.intercomassets.com/assets/oauth/primary-7edb2ebce84c088063f4b86049747c3a.png 1x, https://static.intercomassets.com/assets/oauth/primary@2x-0d69ca2141dfdfa0535634610be80994.png 2x, https://static.intercomassets.com/assets/oauth/primary@3x-788ed3c44d63a6aec3927285e920f542.png 3x"/>
|
78
|
+
</a>
|
79
|
+
<script type="text/javascript">
|
80
|
+
$('.intercom-oauth-cta').unbind('click').click(function() {
|
81
|
+
var auth_window = window.open('/auth/intercom', 'Sign in', 'width=700,height=450');
|
82
|
+
var checkWindow = function() {
|
83
|
+
if (auth_window.closed) {
|
84
|
+
window.location = '/';
|
85
|
+
} else if (window.oauth_success === undefined) {
|
86
|
+
setTimeout(checkWindow, 200);
|
87
|
+
}
|
88
|
+
};
|
89
|
+
checkWindow();
|
90
|
+
});
|
91
|
+
</script>
|
92
|
+
```
|
93
|
+
|
94
|
+
Create a `views/home/intercom_callback.html.erb` file ( if your callback route is `home#intercom_callback`)
|
95
|
+
|
96
|
+
```html
|
97
|
+
<html>
|
98
|
+
<head>
|
99
|
+
<title>Authorized</title>
|
100
|
+
</head>
|
101
|
+
<body>
|
102
|
+
<script type="text/javascript">
|
103
|
+
setTimeout(function() {
|
104
|
+
if (window.opener) {
|
105
|
+
window.opener.oauth_success = true;
|
106
|
+
}
|
107
|
+
window.close();
|
108
|
+
}, 1000);
|
109
|
+
</script>
|
110
|
+
</body>
|
111
|
+
</html>
|
112
|
+
```
|
113
|
+
|
114
|
+
|
115
|
+
### Example application
|
116
|
+
|
117
|
+
[testapp-intercom-omniauth](https://github.com/Skaelv/testapp-intercom-omniauth) is a simple application implementing the authentication process with Intercom with a popup display.
|
@@ -40,7 +40,17 @@ module OmniAuth
|
|
40
40
|
@raw_info ||= access_token.get('/me').parsed
|
41
41
|
end
|
42
42
|
|
43
|
+
def request_phase
|
44
|
+
authorize_url
|
45
|
+
super
|
46
|
+
end
|
47
|
+
|
43
48
|
protected
|
49
|
+
|
50
|
+
def authorize_url
|
51
|
+
options.client_options[:authorize_url] += '/signup' if request.params.fetch('signup', false)
|
52
|
+
end
|
53
|
+
|
44
54
|
def accept_headers
|
45
55
|
access_token.client.connection.headers['Authorization'] = access_token.client.connection.basic_auth(access_token.token, '')
|
46
56
|
access_token.client.connection.headers['Accept'] = "application/vnd.intercom.3+json"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: omniauth-intercom
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kevin Antoine
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-05-
|
11
|
+
date: 2016-05-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: omniauth-oauth2
|