@@ -20,7 +20,7 @@ def edx_authorize_url(base_url):
20
20
Returns:
21
21
str: the authorize url
22
22
"""
23
- return urljoin (base_url , " /oauth2/authorize/" )
23
+ return urljoin (base_url , ' /oauth2/authorize/' )
24
24
25
25
26
26
def edx_access_token_url (base_url ):
@@ -33,29 +33,28 @@ def edx_access_token_url(base_url):
33
33
Returns:
34
34
str: the access token url
35
35
"""
36
- return urljoin (base_url , " /oauth2/access_token/" )
36
+ return urljoin (base_url , ' /oauth2/access_token/' )
37
37
38
38
39
39
class BaseEdxOAuth2 (abc .ABC , BaseOAuth2 ):
40
40
"""
41
41
Base edx OAuth2 authentication backend
42
42
"""
43
-
44
- name = "edxorg"
45
- ID_KEY = "edx_id"
43
+ name = 'edxorg'
44
+ ID_KEY = 'edx_id'
46
45
REQUEST_TOKEN_URL = None
47
46
EDXORG_CALLBACK_URL = None
48
47
49
48
# Settings for Django OAUTH toolkit
50
- DEFAULT_SCOPE = [" read" , " write" ]
49
+ DEFAULT_SCOPE = [' read' , ' write' ]
51
50
52
- ACCESS_TOKEN_METHOD = " POST"
51
+ ACCESS_TOKEN_METHOD = ' POST'
53
52
REDIRECT_STATE = False
54
53
EXTRA_DATA = [
55
- (" refresh_token" , " refresh_token" , True ),
56
- (" expires_in" , " expires_in" ),
57
- (" token_type" , " token_type" , True ),
58
- (" scope" , " scope" ),
54
+ (' refresh_token' , ' refresh_token' , True ),
55
+ (' expires_in' , ' expires_in' ),
56
+ (' token_type' , ' token_type' , True ),
57
+ (' scope' , ' scope' ),
59
58
]
60
59
61
60
@classmethod
@@ -84,9 +83,9 @@ def user_data(self, access_token, *args, **kwargs):
84
83
dict: a dictionary containing user information
85
84
coming from the remote service.
86
85
"""
87
- edx_client = EdxApi ({" access_token" : access_token }, self .EDXORG_CALLBACK_URL )
86
+ edx_client = EdxApi ({' access_token' : access_token }, self .EDXORG_CALLBACK_URL )
88
87
info = edx_client .user_info .get_user_info ()
89
- return {" name" : info .name , " username" : info .username , " email" : info .email }
88
+ return {' name' : info .name , ' username' : info .username , ' email' : info .email }
90
89
91
90
def get_user_details (self , response ):
92
91
"""
@@ -105,16 +104,16 @@ def get_user_details(self, response):
105
104
the following keys:
106
105
<remote_id>, `username`, `email`, `fullname`, `first_name`, `last_name`
107
106
"""
108
- full , _ , _ = self .get_user_names (response [" name" ])
107
+ full , _ , _ = self .get_user_names (response [' name' ])
109
108
110
109
return {
111
- " edx_id" : response [" username" ],
112
- " username" : response [" username" ],
113
- " email" : response [" email" ],
114
- " fullname" : full ,
110
+ ' edx_id' : response [' username' ],
111
+ ' username' : response [' username' ],
112
+ ' email' : response [' email' ],
113
+ ' fullname' : full ,
115
114
# the following are not necessary because they are used only inside the User object.
116
- " first_name" : "" ,
117
- " last_name" : "" ,
115
+ ' first_name' : '' ,
116
+ ' last_name' : '' ,
118
117
}
119
118
120
119
def get_user_id (self , details , response ):
@@ -142,5 +141,5 @@ def refresh_token(self, token, *args, **kwargs):
142
141
dict of information about the user
143
142
"""
144
143
response = super ().refresh_token (token , * args , ** kwargs )
145
- response [" updated_at" ] = now_in_utc ().timestamp ()
144
+ response [' updated_at' ] = now_in_utc ().timestamp ()
146
145
return response
0 commit comments