33from __future__ import unicode_literals
44import json
55
6- from .auth import DeveloperTokenAuth
7- from .config import API
8- from .session .box_session import BoxSession
9- from .network .default_network import DefaultNetwork
10- from .object .user import User
11- from .object .folder import Folder
12- from .object .search import Search
13- from .object .events import Events
14- from .object .file import File
15- from .object .group import Group
16- from .object .group_membership import GroupMembership
17- from .util .shared_link import get_shared_link_header
18- from .util .translator import Translator
6+ from .. auth import OAuth2
7+ from .. config import API
8+ from .. session .box_session import BoxSession
9+ from .. network .default_network import DefaultNetwork
10+ from .. object .user import User
11+ from .. object .folder import Folder
12+ from .. object .search import Search
13+ from .. object .events import Events
14+ from .. object .file import File
15+ from .. object .group import Group
16+ from .. object .group_membership import GroupMembership
17+ from .. util .shared_link import get_shared_link_header
18+ from .. util .translator import Translator
1919
2020
2121class Client (object ):
2222
23- def __init__ (self , oauth , network_layer = None , session = None ):
23+ def __init__ (
24+ self ,
25+ oauth = None ,
26+ network_layer = None ,
27+ session = None ,
28+ client_id = None ,
29+ client_secret = None ,
30+ store_tokens = None ,
31+ ** kwargs
32+ ):
2433 """
2534 :param oauth:
2635 OAuth2 object used by the session to authorize requests.
@@ -34,12 +43,37 @@ def __init__(self, oauth, network_layer=None, session=None):
3443 The session object to use. If None is provided then an instance of :class:`BoxSession` will be used.
3544 :type session:
3645 :class:`BoxSession`
46+ :param client_id:
47+ Box API key used for identifying the application the user is authenticating with.
48+ Ignored if oauth instance is passed into this constructor.
49+ :type client_id:
50+ `unicode`
51+ :param client_secret:
52+ Box API secret used for making OAuth2 requests.
53+ Ignored if oauth instance is passed into this constructor.
54+ :type client_secret:
55+ `unicode`
56+ :param store_tokens:
57+ Optional callback for getting access to tokens for storing them.
58+ Ignored if oauth instance is passed into this constructor.
59+ :type store_tokens:
60+ `callable`
3761 """
3862 network_layer = network_layer or DefaultNetwork ()
39- self ._oauth = oauth
63+ self ._oauth = oauth or OAuth2 ( client_id , client_secret , store_tokens = store_tokens , ** kwargs )
4064 self ._network = network_layer
4165 self ._session = session or BoxSession (oauth = oauth , network_layer = network_layer )
4266
67+ @property
68+ def auth (self ):
69+ """
70+ Get the :class:`OAuth2` instance the client is using for auth to Box.
71+
72+ :rtype:
73+ :class:`OAuth2`
74+ """
75+ return self ._oauth
76+
4377 def folder (self , folder_id ):
4478 """
4579 Initialize a :class:`Folder` object, whose box id is folder_id.
@@ -359,11 +393,3 @@ def with_shared_link(self, shared_link, shared_link_password):
359393 self ._network ,
360394 self ._session .with_shared_link (shared_link , shared_link_password ),
361395 )
362-
363-
364- class DeveloperTokenClient (Client ):
365- """
366- Box client subclass which authorizes with a developer token.
367- """
368- def __init__ (self , oauth = None , network_layer = None , session = None ):
369- super (DeveloperTokenClient , self ).__init__ (oauth or DeveloperTokenAuth (), network_layer , session )
0 commit comments