Skip to content

Commit a978ca6

Browse files
authored
Merge pull request #28 from exeDog/ANA-3170
Add an optional account uuid field in raw info
2 parents 2691f97 + 61525b6 commit a978ca6

3 files changed

Lines changed: 12 additions & 8 deletions

File tree

README.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# OmniAuth Bigcommerce Strategy
22
[![Build Status](https://travis-ci.org/bigcommerce/omniauth-bigcommerce.png?branch=master)](https://travis-ci.org/bigcommerce/omniauth-bigcommerce)
33

4-
This gem provides a dead simple way to authenticate to Bigcommerce using OmniAuth.
4+
This gem provides a simple way to authenticate to Bigcommerce using OmniAuth.
55

66
## Installation
77

@@ -42,22 +42,23 @@ It defaults to https://login.bigcommerce.com if the env variable is not defined.
4242

4343
## Auth Hash Schema
4444

45-
The following information is provided back to you for this provider:
45+
The following response format is provided back to you for this provider:
4646

4747
```
4848
{
4949
uid: '12345',
5050
info: {
51-
name: 'Philip Muir',
52-
email: 'philip.muir@example.com'
51+
name: 'John Doe',
52+
email: 'john.doe@example.com'
5353
},
5454
credentials: {
5555
token: 'xyz123abc'
5656
},
5757
extra: {
5858
raw_info: {},
5959
scopes: 'requested_scopes store_v2_settings'
60-
context: 'store/xyz123'
60+
context: 'store/xyz123',
61+
account_uuid: 'fooBar'
6162
}
6263
}
6364
```

lib/omniauth/strategies/bigcommerce.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class BigCommerce < OmniAuth::Strategies::OAuth2
2525
option :provider_ignores_state, true
2626
option :scope, 'users_basic_information'
2727
option :authorize_options, [:scope, :context]
28-
option :token_options, [:scope, :context]
28+
option :token_options, [:scope, :context, :account_uuid]
2929
option :client_options,
3030
site: ENV.fetch('BC_AUTH_SERVICE', 'https://login.bigcommerce.com'),
3131
authorize_url: '/oauth2/authorize',
@@ -51,7 +51,8 @@ class BigCommerce < OmniAuth::Strategies::OAuth2
5151
{
5252
raw_info: raw_info,
5353
scopes: raw_info['scope'],
54-
context: raw_info['context']
54+
context: raw_info['context'],
55+
account_uuid: raw_info.fetch('account_uuid', '')
5556
}
5657
end
5758

spec/omniauth/strategies/bigcommerce_spec.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
let(:store_hash) { 'abcdefg' }
55
let(:context) { "stores/#{store_hash}" }
66
let(:scope) { 'store_v2_products' }
7-
let(:request) { double('Request', :params => { 'context' => context, 'scope' => scope }, :cookies => {}, :env => {}) }
7+
let(:account_uuid) { 'foobar' }
8+
let(:request) { double('Request', params: { 'context' => context, 'scope' => scope, 'account_uuid' => account_uuid }, cookies: {}, env: {}) }
89

910
before do
1011
OmniAuth.config.test_mode = true
@@ -71,6 +72,7 @@
7172
it 'should set the context and scope parameters in the token request' do
7273
expect(subject.token_params['context']).to eq(context)
7374
expect(subject.token_params['scope']).to eq(scope)
75+
expect(subject.token_params['account_uuid']).to eq(account_uuid)
7476
end
7577
end
7678
end

0 commit comments

Comments
 (0)