Skip to content

Commit

Permalink
Merge pull request googleapis#185 from frennkie/add-directory-id
Browse files Browse the repository at this point in the history
add tenant_id parameter to Connection class
  • Loading branch information
Alejandro Casanovas authored Feb 5, 2019
2 parents 119b6dc + ccd8433 commit 972a9fa
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions O365/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,17 +252,13 @@ def __init__(self, api_version='v2.0', default_resource=ME_RESOURCE,
class Connection:
""" Handles all communication (requests) between the app and the server """

_oauth2_authorize_url = 'https://login.microsoftonline.com/common/' \
'oauth2/v2.0/authorize'
_oauth2_token_url = 'https://login.microsoftonline.com/common/' \
'oauth2/v2.0/token'
_allowed_methods = ['get', 'post', 'put', 'patch', 'delete']

def __init__(self, credentials, *, scopes=None,
proxy_server=None, proxy_port=8080, proxy_username=None,
proxy_password=None, requests_delay=200, raise_http_errors=True,
request_retries=3, token_file_name=None, token_backend=None,
**kwargs):
tenant_id="common", **kwargs):
""" Creates an API connection object
:param tuple credentials: a tuple of (client_id, client_secret)
Expand All @@ -288,6 +284,7 @@ def __init__(self, credentials, *, scopes=None,
storing the OAuth token credentials.
:param BaseTokenBackend token_backend: the token backend used to get
and store tokens
:param str tenant_id: use this specific tenant id, defaults to common
:param dict kwargs: any extra params passed to Connection
:raises ValueError: if credentials is not tuple of
(client_id, client_secret)
Expand Down Expand Up @@ -328,6 +325,11 @@ def __init__(self, credentials, *, scopes=None,
self.naive_session.mount('http://', adapter)
self.naive_session.mount('https://', adapter)

self._oauth2_authorize_url = 'https://login.microsoftonline.com/' \
'{}/oauth2/v2.0/authorize'.format(tenant_id)
self._oauth2_token_url = 'https://login.microsoftonline.com/' \
'{}/oauth2/v2.0/token'.format(tenant_id)

def set_proxy(self, proxy_server, proxy_port, proxy_username,
proxy_password):
""" Sets a proxy on the Session
Expand Down

0 comments on commit 972a9fa

Please sign in to comment.