Skip to content

Commit 798aa77

Browse files
committed
Merge branch 'generic-authcode-cli' into dev
2 parents 75a378e + b99d464 commit 798aa77

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

tests/authcode.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@
1111
from urllib import urlencode
1212

1313

14-
def build_auth_endpoint(tenant, client_id): # Microsoft specific
15-
return ( # Lucky that redirect_uri can be omitted, so it works for any app
16-
"https://login.microsoftonline.com/{t}/oauth2/authorize" # V1 endpoint
17-
"?response_type=code&client_id={c}").format(t=tenant, c=client_id)
14+
def build_auth_url(authority, client_id):
15+
# Lucky that redirect_uri can be omitted, so it works for any app
16+
return "{a}/oauth2/authorize?response_type=code&client_id={c}".format(
17+
a=authority, c=client_id)
1818

1919
class AuthCodeReceiver(BaseHTTPRequestHandler):
2020
"""A one-stop solution to acquire an authorization code.
@@ -67,10 +67,11 @@ def send_full_response(self, body, is_ok=True):
6767
p = parser = argparse.ArgumentParser(
6868
description=AuthCodeReceiver.__doc__
6969
+ "The auth code received will be dumped into stdout.")
70-
p.add_argument('tenant', help="The tenant which your app will serve for")
7170
p.add_argument('client_id', help="The client_id of your web service app")
7271
p.add_argument('redirect_port', type=int, help="The port in redirect_uri")
72+
p.add_argument(
73+
"--authority", default="https://login.microsoftonline.com/common")
7374
args = parser.parse_args()
7475
print(AuthCodeReceiver.acquire(
75-
build_auth_endpoint(args.tenant, args.client_id), args.redirect_port))
76+
build_auth_url(args.authority, args.client_id), args.redirect_port))
7677

0 commit comments

Comments
 (0)