File tree Expand file tree Collapse file tree 2 files changed +33
-7
lines changed Expand file tree Collapse file tree 2 files changed +33
-7
lines changed Original file line number Diff line number Diff line change @@ -118,9 +118,9 @@ def login(
118
118
self ,
119
119
username ,
120
120
password ,
121
- scope ,
122
- realm ,
123
- audience ,
121
+ scope = None ,
122
+ realm = None ,
123
+ audience = None ,
124
124
grant_type = "http://auth0.com/oauth/grant-type/password-realm" ,
125
125
):
126
126
"""Calls /oauth/token endpoint with password-realm grant type
@@ -134,18 +134,18 @@ def login(
134
134
this information.
135
135
136
136
Args:
137
- audience (str): The unique identifier of the target API you want to access.
138
-
139
137
username (str): Resource owner's identifier
140
138
141
139
password (str): resource owner's Secret
142
140
143
- scope(str): String value of the different scopes the client is asking for.
141
+ scope(str, optional ): String value of the different scopes the client is asking for.
144
142
Multiple scopes are separated with whitespace.
145
143
146
- realm (str): String value of the realm the user belongs.
144
+ realm (str, optional ): String value of the realm the user belongs.
147
145
Set this if you want to add realm support at this grant.
148
146
147
+ audience (str, optional): The unique identifier of the target API you want to access.
148
+
149
149
grant_type (str, optional): Denotes the flow you're using. For password realm
150
150
use http://auth0.com/oauth/grant-type/password-realm
151
151
Original file line number Diff line number Diff line change @@ -163,6 +163,32 @@ def test_login(self, mock_post):
163
163
},
164
164
)
165
165
166
+ @mock .patch ("auth0.rest.RestClient.post" )
167
+ def test_login_simple (self , mock_post ):
168
+ g = GetToken ("my.domain.com" , "cid" , client_secret = "clsec" )
169
+
170
+ g .login (
171
+ username = "usrnm" ,
172
+ password = "pswd" ,
173
+ )
174
+
175
+ args , kwargs = mock_post .call_args
176
+
177
+ self .assertEqual (args [0 ], "https://my.domain.com/oauth/token" )
178
+ self .assertEqual (
179
+ kwargs ["data" ],
180
+ {
181
+ "client_id" : "cid" ,
182
+ "client_secret" : "clsec" ,
183
+ "username" : "usrnm" ,
184
+ "password" : "pswd" ,
185
+ "realm" : None ,
186
+ "scope" : None ,
187
+ "audience" : None ,
188
+ "grant_type" : "http://auth0.com/oauth/grant-type/password-realm" ,
189
+ },
190
+ )
191
+
166
192
@mock .patch ("auth0.rest.RestClient.post" )
167
193
def test_refresh_token (self , mock_post ):
168
194
g = GetToken ("my.domain.com" , "cid" , client_secret = "clsec" )
You can’t perform that action at this time.
0 commit comments