Skip to content
This repository was archived by the owner on Oct 2, 2024. It is now read-only.

Commit 2e5c612

Browse files
author
Daniel Masson
committed
Added support for resource param in the authenticate mathod, useful for OneDrive for Business use cases
1 parent b806b39 commit 2e5c612

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

src/onedrivesdk/auth_provider.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ def get_auth_url(self, redirect_uri):
134134
}
135135
return "{}?{}".format(self.AUTH_SERVER_URL, urlencode(params))
136136

137-
def authenticate(self, code, redirect_uri, client_secret=None):
137+
def authenticate(self, code, redirect_uri, client_secret=None, resource=None):
138138
"""Takes in a code string, gets the access token,
139139
and creates session property bag
140140
@@ -145,17 +145,23 @@ def authenticate(self, code, redirect_uri, client_secret=None):
145145
to
146146
client_secret (str): Defaults to None, the client
147147
secret of your app
148+
resource (str): Defaults to None,The resource
149+
you want to access
148150
"""
149151

150152
params = {
151153
"code": code,
152154
"client_id": self.client_id,
153155
"redirect_uri": redirect_uri,
154-
"grant_type": "authorization_code"
156+
"grant_type": "authorization_code",
157+
"resource": resource,
155158
}
156159

157160
if client_secret is not None:
158161
params["client_secret"] = client_secret
162+
if resource is not None:
163+
params["resource"] = resource
164+
159165
headers = {"Content-Type": "application/x-www-form-urlencoded"}
160166
response = self._http_provider.send(method="POST",
161167
headers=headers,

src/onedrivesdk/auth_provider_base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ def get_auth_url(self, auth_server_url, redirect_uri):
6363
pass
6464

6565
@abc.abstractmethod
66-
def authenticate(self, code, auth_server_url, redirect_uri, client_secret):
66+
def authenticate(self, code, auth_server_url, redirect_uri, client_secret, resource):
6767
pass
6868

6969
@abc.abstractmethod

0 commit comments

Comments
 (0)