Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 5c631cd

Browse files
authored
Make pw realm params optional (auth0#484)
2 parents 1e2b7be + 6feb1f2 commit 5c631cd

File tree

2 files changed

+33
-7
lines changed

2 files changed

+33
-7
lines changed

auth0/authentication/get_token.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -118,9 +118,9 @@ def login(
118118
self,
119119
username,
120120
password,
121-
scope,
122-
realm,
123-
audience,
121+
scope=None,
122+
realm=None,
123+
audience=None,
124124
grant_type="http://auth0.com/oauth/grant-type/password-realm",
125125
):
126126
"""Calls /oauth/token endpoint with password-realm grant type
@@ -134,18 +134,18 @@ def login(
134134
this information.
135135
136136
Args:
137-
audience (str): The unique identifier of the target API you want to access.
138-
139137
username (str): Resource owner's identifier
140138
141139
password (str): resource owner's Secret
142140
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.
144142
Multiple scopes are separated with whitespace.
145143
146-
realm (str): String value of the realm the user belongs.
144+
realm (str, optional): String value of the realm the user belongs.
147145
Set this if you want to add realm support at this grant.
148146
147+
audience (str, optional): The unique identifier of the target API you want to access.
148+
149149
grant_type (str, optional): Denotes the flow you're using. For password realm
150150
use http://auth0.com/oauth/grant-type/password-realm
151151

auth0/test/authentication/test_get_token.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,32 @@ def test_login(self, mock_post):
163163
},
164164
)
165165

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+
166192
@mock.patch("auth0.rest.RestClient.post")
167193
def test_refresh_token(self, mock_post):
168194
g = GetToken("my.domain.com", "cid", client_secret="clsec")

0 commit comments

Comments
 (0)