33 https://python-social-auth.readthedocs.io/en/latest/backends/shopify.html
44"""
55
6- import imp # type: ignore[reportMissingImports]
6+ import shopify
77
88from ..exceptions import AuthCanceled , AuthFailed
99from ..utils import handle_http_errors
@@ -22,13 +22,6 @@ class ShopifyOAuth2(BaseOAuth2):
2222 def shopify_api_version (self ):
2323 return self .setting ("API_VERSION" , "2020-10" )
2424
25- @property
26- def shopify_api (self ):
27- if not hasattr (self , "_shopify_api" ):
28- fp , pathname , description = imp .find_module ("shopify" )
29- self ._shopify_api = imp .load_module ("shopify" , fp , pathname , description )
30- return self ._shopify_api
31-
3225 def get_user_details (self , response ):
3326 """Use the shopify store name as the username"""
3427 return {"username" : str (response .get ("shop" , "" )).replace (".myshopify.com" , "" )}
@@ -37,7 +30,7 @@ def extra_data(self, user, uid, response, details=None, *args, **kwargs):
3730 """Return access_token and extra defined names to store in
3831 extra_data field"""
3932 data = super ().extra_data (user , uid , response , details , * args , ** kwargs )
40- session = self . shopify_api .Session (
33+ session = shopify .Session (
4134 self .data .get ("shop" ).strip (), version = self .shopify_api_version
4235 )
4336 # Get, and store the permanent token
@@ -47,12 +40,12 @@ def extra_data(self, user, uid, response, details=None, *args, **kwargs):
4740
4841 def auth_url (self ):
4942 key , secret = self .get_key_and_secret ()
50- self . shopify_api .Session .setup (api_key = key , secret = secret )
43+ shopify .Session .setup (api_key = key , secret = secret )
5144 scope = self .get_scope ()
5245 state = self .state_token ()
5346 self .strategy .session_set (self .name + "_state" , state )
5447 redirect_uri = self .get_redirect_uri (state )
55- session = self . shopify_api .Session (
48+ session = shopify .Session (
5649 self .data .get ("shop" ).strip (), version = self .shopify_api_version
5750 )
5851 return session .create_permission_url (scope = scope , redirect_uri = redirect_uri )
@@ -65,12 +58,12 @@ def auth_complete(self, *args, **kwargs):
6558 key , secret = self .get_key_and_secret ()
6659 try :
6760 shop_url = self .data .get ("shop" )
68- self . shopify_api .Session .setup (api_key = key , secret = secret )
69- shopify_session = self . shopify_api .Session (
61+ shopify .Session .setup (api_key = key , secret = secret )
62+ shopify_session = shopify .Session (
7063 shop_url , version = self .shopify_api_version , token = self .data
7164 )
7265 access_token = shopify_session .token
73- except self . shopify_api .ValidationException :
66+ except shopify .ValidationException :
7467 raise AuthCanceled (self )
7568 else :
7669 if not access_token :
0 commit comments