omniauth-hubspot 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +44 -1
- data/lib/omniauth/hubspot/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 249b3d1775295254324b7d14b5678ce1aa83e9fa
|
4
|
+
data.tar.gz: c00e30697540398d0b7c437ec5b8469be47fd691
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0c23e4481907c3e2eec6f7f3268bf424c9aa453bbe6cfc3eeee3811e12c5521a4ac3cb5bfb89b68ceaa46d355bc9f9d87a0c1da409502b4e3bac7f887dc079e2
|
7
|
+
data.tar.gz: 0a6a8ce7068c86168e9da5ab4808119ebbbb831f284ac54b0850fa7b88d3242af9d59f706d1cd05af3cfb1da9e349cd5a49e76ba7ba9adf83e6ed9e75c88c859
|
data/README.md
CHANGED
@@ -1,4 +1,47 @@
|
|
1
|
-
|
1
|
+
OmniAuth HubSpot
|
2
2
|
================
|
3
3
|
|
4
4
|
An OmniAuth strategy for authenticating with the HubSpot API.
|
5
|
+
|
6
|
+
## Peculiarities
|
7
|
+
|
8
|
+
HubSpot has some peculiarities in their implementation of OAuth that I've accounted for in this strategy. Be aware that the authorization process does not use OAuth2's state parameter for securing sessions. Additionally, it does not use the POST to token URL phase of OAuth; instead, the tokens we need are passed as parameters right after the initial request phase. HubSpot also authenticates with only a Client ID and a Portal ID, instead of the standard Client ID and Client Secret.
|
9
|
+
|
10
|
+
## Installing
|
11
|
+
|
12
|
+
Add the gem to your `Gemfile` and then `bundle install`.
|
13
|
+
|
14
|
+
```ruby
|
15
|
+
gem 'omniauth-hubspot'
|
16
|
+
```
|
17
|
+
|
18
|
+
## Usage
|
19
|
+
|
20
|
+
You will need to define a custom [setup phase](https://github.com/intridea/omniauth/wiki/Setup-Phase) for this strategy to work. This is because [HubSpot requires a `portalId` to be set](https://developers.hubspot.com/auth/oauth_apps), which is customer-specific and therefore cannot be simply passed as a parameter to provider. The above setup phase link should give you an idea of the different ways to do this. My setup phase code looks roughly like the following.
|
21
|
+
|
22
|
+
```ruby
|
23
|
+
def setup
|
24
|
+
request.env['omniauth.strategy'].options[:portalId] = params[:hubspot][:portal_id]
|
25
|
+
|
26
|
+
render text: "Omniauth setup phase.", status: 404
|
27
|
+
end
|
28
|
+
```
|
29
|
+
|
30
|
+
If you are using multiple providers, you'll want to wrap an if statement around that so that you only set it when you're using HubSpot.
|
31
|
+
|
32
|
+
Then, when adding the provider to your `omniauth.rb`, you will only need to specify a `client_id` and a `scope`. HubSpot's supported scopes are [here](https://developers.hubspot.com/auth/oauth_scopes). Note that although the documentation states to separate scopes with a `+`, you will actually need to use a space, as this is escaped into a `+`. Here is an example provider line:
|
33
|
+
|
34
|
+
```ruby
|
35
|
+
provider :hubspot, ENV['HUBSPOT_CLIENT_ID'], setup: true, scope: "contacts-rw offline"
|
36
|
+
```
|
37
|
+
|
38
|
+
Be sure to specify the `offline` scope if you want to get a refresh token that you can use to renew your access token.
|
39
|
+
|
40
|
+
## Contributing
|
41
|
+
|
42
|
+
Fork, create a branch, and create a pull request when you're done.
|
43
|
+
|
44
|
+
## License
|
45
|
+
|
46
|
+
Copyright (C) 2014 Daniel Arnold
|
47
|
+
GPL v3.
|