2222logger = logging .getLogger (__name__ )
2323
2424def decorate_scope (
25- scope , client_id ,
26- policy = None , # obsolete
25+ scopes , client_id ,
2726 reserved_scope = frozenset (['openid' , 'profile' , 'offline_access' ])):
28- scope_set = set (scope ) # Input scope is typically a list. Copy it to a set.
27+ if not isinstance (scopes , (list , set , tuple )):
28+ raise ValueError ("The input scopes should be a list, tuple, or set" )
29+ scope_set = set (scopes ) # Input scopes is typically a list. Copy it to a set.
2930 if scope_set & reserved_scope :
3031 # These scopes are reserved for the API to provide good experience.
3132 # We could make the developer pass these and then if they do they will
@@ -108,9 +109,9 @@ def _build_client(self, client_credential, authority):
108109
109110 def get_authorization_request_url (
110111 self ,
111- scope ,
112- additional_scope = frozenset ([]) , # Not yet supported
113- login_hint = None ,
112+ scopes , # type: list[str]
113+ # additional_scope=None , # type: Optional[list]
114+ login_hint = None , # type: Optional[str]
114115 state = None , # Recommended by OAuth2 for CSRF protection
115116 redirect_uri = None ,
116117 authority = None , # By default, it will use self.authority;
@@ -119,15 +120,21 @@ def get_authorization_request_url(
119120 ** kwargs ):
120121 """Constructs a URL for you to start a Authorization Code Grant.
121122
122- :param scope: Scope refers to the resource that will be used in the
123- resulting token's audience.
123+ :param scopes:
124+ Scopes requested to access a protected API (a resource).
125+ :param str state: Recommended by OAuth2 for CSRF protection.
126+ :param login_hint:
127+ Identifier of the user. Generally a User Principal Name (UPN).
128+ :param redirect_uri:
129+ Address to return to upon receiving a response from the authority.
130+ """
131+ """ # TBD: this would only be meaningful in a new acquire_token_interactive()
124132 :param additional_scope: Additional scope is a concept only in AAD.
125133 It refers to other resources you might want to prompt to consent
126134 for in the same interaction, but for which you won't get back a
127135 token for in this particular operation.
128136 (Under the hood, we simply merge scope and additional_scope before
129137 sending them on the wire.)
130- :param str state: Recommended by OAuth2 for CSRF protection.
131138 """
132139 the_authority = Authority (authority ) if authority else self .authority
133140 client = Client (
@@ -136,7 +143,7 @@ def get_authorization_request_url(
136143 return client .build_auth_request_uri (
137144 response_type = "code" , # Using Authorization Code grant
138145 redirect_uri = redirect_uri , state = state , login_hint = login_hint ,
139- scope = decorate_scope (scope , self .client_id ),
146+ scope = decorate_scope (scopes , self .client_id ),
140147 )
141148
142149 def acquire_token_with_authorization_code (
0 commit comments