@@ -16,17 +16,18 @@ class Client(object):
1616 OFFICE365_AUTH_ENDPOINT = '/oauth20_authorize.srf?'
1717 OFFICE365_TOKEN_ENDPOINT = '/oauth20_token.srf'
1818
19- def __init__ (self , client_id , client_secret , api_version = 'v1.0' , account_type = 'common' ):
19+ def __init__ (self , client_id , client_secret , api_version = 'v1.0' , account_type = 'common' , office365 = False ):
2020 self .client_id = client_id
2121 self .client_secret = client_secret
2222 self .api_version = api_version
2323 self .account_type = account_type
2424
2525 self .base_url = self .RESOURCE + self .api_version + '/'
2626 self .token = None
27+ self .office365 = office365
2728 self .office365_token = None
2829
29- def authorization_url (self , redirect_uri , scope , state = None , office365 = False ):
30+ def authorization_url (self , redirect_uri , scope , state = None ):
3031 """
3132
3233 Args:
@@ -42,8 +43,6 @@ def authorization_url(self, redirect_uri, scope, state=None, office365=False):
4243 about the user's state in the app before the authentication request occurred, such as the page or view
4344 they were on.
4445
45- office365: Get authorization url for office 365 instead graph.
46-
4746 Returns:
4847 A string.
4948
@@ -58,13 +57,13 @@ def authorization_url(self, redirect_uri, scope, state=None, office365=False):
5857
5958 if state :
6059 params ['state' ] = None
61- if office365 :
60+ if self . office365 :
6261 response = self .OFFICE365_AUTHORITY_URL + self .OFFICE365_AUTH_ENDPOINT + urlencode (params )
6362 else :
6463 response = self .AUTHORITY_URL + self .account_type + self .AUTH_ENDPOINT + urlencode (params )
6564 return response
6665
67- def exchange_code (self , redirect_uri , code , office365 = False ):
66+ def exchange_code (self , redirect_uri , code ):
6867 """Exchanges a code for a Token.
6968
7069 Args:
@@ -73,8 +72,6 @@ def exchange_code(self, redirect_uri, code, office365=False):
7372
7473 code: The authorization_code that you acquired in the first leg of the flow.
7574
76- office365: Exchange code for office 365 instead graph.
77-
7875 Returns:
7976 A dict.
8077
@@ -86,13 +83,13 @@ def exchange_code(self, redirect_uri, code, office365=False):
8683 'code' : code ,
8784 'grant_type' : 'authorization_code' ,
8885 }
89- if office365 :
86+ if self . office365 :
9087 response = requests .post (self .OFFICE365_AUTHORITY_URL + self .OFFICE365_TOKEN_ENDPOINT , data = data )
9188 else :
9289 response = requests .post (self .AUTHORITY_URL + self .account_type + self .TOKEN_ENDPOINT , data = data )
9390 return self ._parse (response )
9491
95- def refresh_token (self , redirect_uri , refresh_token , office365 = False ):
92+ def refresh_token (self , redirect_uri , refresh_token ):
9693 """
9794
9895 Args:
@@ -103,8 +100,6 @@ def refresh_token(self, redirect_uri, refresh_token, office365=False):
103100 after the current access token expires. Refresh tokens are long-lived, and can be used to retain access
104101 to resources for extended periods of time.
105102
106- office365: Refresh token for office 365 instead graph.
107-
108103 Returns:
109104 A dict.
110105
@@ -116,22 +111,20 @@ def refresh_token(self, redirect_uri, refresh_token, office365=False):
116111 'refresh_token' : refresh_token ,
117112 'grant_type' : 'refresh_token' ,
118113 }
119- if office365 :
114+ if self . office365 :
120115 response = requests .post (self .OFFICE365_AUTHORITY_URL + self .OFFICE365_TOKEN_ENDPOINT , data = data )
121116 else :
122117 response = requests .post (self .AUTHORITY_URL + self .account_type + self .TOKEN_ENDPOINT , data = data )
123118 return self ._parse (response )
124119
125- def set_token (self , token , office365 = False ):
120+ def set_token (self , token ):
126121 """Sets the Token for its use in this library.
127122
128123 Args:
129124 token: A string with the Token.
130125
131- office365: Set token for office 365 instead graph.
132-
133126 """
134- if office365 :
127+ if self . office365 :
135128 self .office365_token = token
136129 else :
137130 self .token = token
@@ -563,12 +556,12 @@ def _patch(self, url, **kwargs):
563556 def _delete (self , url , ** kwargs ):
564557 return self ._request ('DELETE' , url , ** kwargs )
565558
566- def _request (self , method , url , headers = None , office365 = False , ** kwargs ):
559+ def _request (self , method , url , headers = None , ** kwargs ):
567560 _headers = {
568561 'Accept' : 'application/json' ,
569562 'Content-Type' : 'application/json'
570563 }
571- if office365 :
564+ if self . office365 :
572565 _headers ['Authorization' ] = 'Bearer ' + self .office365_token ['access_token' ]
573566 else :
574567 _headers ['Authorization' ] = 'Bearer ' + self .token ['access_token' ]
0 commit comments