Skip to content

Commit d1be5f5

Browse files
committed
Experimental OAuth2 client secret flow
1 parent 549ee7a commit d1be5f5

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

msal/application.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import requests
12

23

34
class ClientApplication(object):
@@ -34,6 +35,13 @@ def __init__(self, client_id, client_credential, user_token_cache, **kwargs):
3435
self.user_token_cache = user_token_cache
3536
self.app_token_cache = None # TODO
3637

37-
def acquire_token_for_client(self, scope, policy=None): # Can policy default to None?
38-
pass
38+
def acquire_token_for_client(self, scope, policy=None):
39+
data = {
40+
'grant_type': 'client_credentials', 'client_id': self.client_id,
41+
'scope': scope}
42+
if True: # TODO: Need to differenciate the certificate use case
43+
data['client_secret'] = self.client_credential
44+
return requests.post(
45+
self.authority + self.TOKEN_ENDPOINT_PATH, params={'p': policy},
46+
headers={'Accept': 'application/json'}, data=data).json()
3947

requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
requests>=2,<3

0 commit comments

Comments
 (0)