Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated to use latest api wrapper #386

Merged
merged 2 commits into from Sep 23, 2014
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/backends/shopify.rst
Expand Up @@ -4,7 +4,7 @@ Shopify
Shopify uses OAuth 2 for authentication.

To use this backend, you must install the package ``shopify`` from the `Github
project`_.
project`_. Currently supports v2+

- Register a new application at `Shopify Partners`_, and

Expand Down
20 changes: 17 additions & 3 deletions social/backends/shopify.py
Expand Up @@ -32,19 +32,32 @@ def shopifyAPI(self):
def get_user_details(self, response):
"""Use the shopify store name as the username"""
return {
'username': six.text_type(response.get('shop', ''), 'utf-8')
'username': six.text_type(response.get('shop', ''))
.replace('.myshopify.com', '')
}


def extra_data(self, user, uid, response, details=None):
"""Return access_token and extra defined names to store in
extra_data field"""
data = super(BaseOAuth2, self).extra_data(user, uid, response, details)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Skipping a class?

session = self.shopifyAPI.Session(self.data.get('shop').strip())
# Get, and store the permanent token
token = session.request_token(data["access_token"].dicts[1])
data["access_token"] = token

return dict(data)

def auth_url(self):
key, secret = self.get_key_and_secret()
self.shopifyAPI.Session.setup(api_key=key, secret=secret)
scope = self.get_scope()
state = self.state_token()
self.strategy.session_set(self.name + '_state', state)
redirect_uri = self.get_redirect_uri(state)
return self.shopifyAPI.Session.create_permission_url(
self.data.get('shop').strip(),
session = self.shopifyAPI.Session(self.data.get('shop').strip())

return session.create_permission_url(
scope=scope,
redirect_uri=redirect_uri
)
Expand Down Expand Up @@ -82,3 +95,4 @@ def do_auth(self, access_token, shop_url, website, *args, **kwargs):
}
})
return self.strategy.authenticate(*args, **kwargs)