Skip to content

Commit f43be63

Browse files
committed
Update the docs
1 parent 134fac6 commit f43be63

File tree

16 files changed

+58
-53
lines changed

16 files changed

+58
-53
lines changed

docs/latest/_sources/getting_started.rst.txt

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,13 @@ A common pattern to check for authentication and use the library is this one:
5959

6060
.. code-block:: python
6161
62-
scopes = ['my_required_scopes'] # you can use scope helpers here (see Permissions and Scopes section)
62+
requested_scopes = ['my_required_scopes'] # you can use scope helpers here (see Permissions and Scopes section)
6363
6464
account = Account(credentials)
6565
6666
if not account.is_authenticated: # will check if there is a token and has not expired
6767
# ask for a login using console based authentication. See Authentication for other flows
68-
if account.authenticate(scopes=scopes) is False:
68+
if account.authenticate(requested_scopes=requeated_scopes) is False:
6969
raise RuntimeError('Authentication Failed')
7070
7171
# now we are authenticated
@@ -228,7 +228,7 @@ To authenticate (login) you can use :ref:`different_interfaces`. On the followin
228228
# the default authentication method will be "on behalf of a user"
229229
230230
account = Account(credentials)
231-
if account.authenticate(scopes=['basic', 'message_all']):
231+
if account.authenticate(requested_scopes=['basic', 'message_all']):
232232
print('Authenticated!')
233233
234234
# 'basic' adds: 'https://graph.microsoft.com/User.Read'
@@ -281,7 +281,7 @@ To accomplish the authentication you can basically use different approaches. The
281281
You can authenticate using a console. The best way to achieve this is by using the authenticate method of the Account class.
282282

283283
account = Account(credentials)
284-
account.authenticate(scopes=['basic', 'message_all'])
284+
account.authenticate(requested_scopes=['basic', 'message_all'])
285285
The authenticate method will print into the console an url that you will have to visit to achieve authentication. Then after visiting the link and authenticate you will have to paste back the resulting url into the console. The method will return True and print a message if it was succesful.
286286

287287
**Tip:** When using macOS the console is limited to 1024 characters. If your url has multiple scopes it can exceed this limit. To solve this. Just import readline at the top of your script.
@@ -370,14 +370,14 @@ For example your application can have Calendar.Read, Mail.ReadWrite and Mail.Sen
370370
371371
credentials = ('client_id', 'client_secret')
372372
373-
scopes = ['Mail.ReadWrite', 'Mail.Send']
373+
requested_scopes = ['Mail.ReadWrite', 'Mail.Send']
374374
375-
account = Account(credentials, scopes=scopes)
375+
account = Account(credentials, requested_scopes=requested_scopes)
376376
account.authenticate()
377377
378378
# The latter is exactly the same as passing scopes to the authenticate method like so:
379379
# account = Account(credentials)
380-
# account.authenticate(scopes=scopes)
380+
# account.authenticate(requested_scopes=requested_scopes)
381381
382382
Scope implementation depends on the protocol used. So by using protocol data you can automatically set the scopes needed. This is implemented by using 'scope helpers'. Those are little helpers that group scope functionality and abstract the protocol used.
383383

@@ -419,7 +419,7 @@ You can get the same scopes as before using protocols and scope helpers like thi
419419
scopes_graph = protocol.get_scopes_for('message_all')
420420
# scopes here are: ['https://graph.microsoft.com/Mail.ReadWrite', 'https://graph.microsoft.com/Mail.Send']
421421
422-
account = Account(credentials, scopes=scopes_graph)
422+
account = Account(credentials, requested_scopes=scopes_graph)
423423
424424
.. note::
425425

docs/latest/_sources/usage/account.rst.txt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -88,11 +88,11 @@ Setting Scopes
8888
8989
# Full permission to your mail
9090
account = Account(credentials=('my_client_id', 'my_client_secret'),
91-
scopes=['message_all'])
91+
requested_scopes=['message_all'])
9292
9393
# Why change every time, add all at a time :)
9494
account = Account(credentials=('my_client_id', 'my_client_secret'),
95-
scopes=['message_all', 'message_all_shared', 'address_book_all',
95+
requested_scopes=['message_all', 'message_all_shared', 'address_book_all',
9696
'address_book_all_shared',
9797
'calendar', 'users', 'onedrive', 'sharepoint_dl'])
9898
@@ -143,8 +143,8 @@ You can work only with the required pieces:
143143
from O365.mailbox import MailBox
144144
145145
protocol = MSGraphProtocol()
146-
scopes = ['...']
147-
con = Connection(('client_id', 'client_secret'), scopes=scopes)
146+
requested_scopes = ['...']
147+
con = Connection(('client_id', 'client_secret'), requested_scopes=requested_scopes)
148148
149149
message = Message(con=con, protocol=protocol)
150150
# ...
@@ -186,7 +186,7 @@ It's also easy to implement a custom Class. Just Inherit from ApiComponent, defi
186186
from O365 import Connection, MSGraphProtocol
187187
188188
protocol = MSGraphProtocol() # or maybe a user defined protocol
189-
con = Connection(('client_id', 'client_secret'), scopes=protocol.get_scopes_for(['...']))
189+
con = Connection(('client_id', 'client_secret'), requested_scopes=protocol.get_scopes_for(['...']))
190190
custom_class = CustomClass(con=con, protocol=protocol)
191191
192192
custom_class.do_some_stuff()

docs/latest/_sources/usage/addressbook.rst.txt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,15 +64,16 @@ Without admin consent you can only access a few properties of each user such as
6464
To search the Global Address List (Users API):
6565

6666
.. code-block:: python
67-
67+
6868
global_address_list = account.directory()
6969
7070
# for backwards compatibility only this also works and returns a Directory object:
7171
# global_address_list = account.address_book(address_book='gal')
7272
7373
# start a new query:
74-
q = global_address_list.new_query('display_name')
75-
q.startswith('George Best')
74+
builder = global_address_list.new_query()
75+
query = builder.select('display_name')
76+
query = query & builder.startswith('subject', 'George Best')
7677
7778
for user in global_address_list.get_users(query=q):
7879
print(user)

docs/latest/_sources/usage/calendar.rst.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,13 @@ Working with Calendar instances:
4646
4747
calendar = schedule.get_calendar(calendar_name='Birthdays')
4848
49+
builder = calendar.new_query()
4950
calendar.name = 'Football players birthdays'
5051
calendar.update()
5152
5253
53-
start_q = calendar.new_query('start').greater_equal(dt.datetime(2018, 5, 20))
54-
end_q = calendar.new_query('start').less_equal(dt.datetime(2018, 5, 24))
54+
start_q = builder.greater_equal('start', dt.datetime(2018, 5, 20))
55+
end_q = builder.greater_equal('start', dt.datetime(2018, 5, 24))
5556
5657
birthdays = calendar.get_events(
5758
include_recurring=True, # include_recurring=True will include repeated events on the result set.

docs/latest/_sources/usage/mailbox.rst.txt

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,8 @@ MailboxSettings.ReadWrite mailbox_settings To read and
8787
.. .. code-block:: python
8888
8989
.. # All child folders whose name startswith 'Top'
90-
.. mail_folders = mailbox.get_folders(query=mailbox.new_query('displayName').startswith('Top'))
90+
.. builder = mailbox.new_query()
91+
.. mail_folders = mailbox.get_folders(query=builder.startswith('displayName', 'Top'))
9192
9293
Mailbox and Messages
9394
""""""""""""""""""""
@@ -152,8 +153,9 @@ Creating a draft message is as easy as this:
152153
**Working with saved emails is also easy**
153154

154155
.. code-block:: python
155-
156-
query = mailbox.new_query().on_attribute('subject').contains('george best') # see Query object in Utils
156+
157+
builder = mailbox.new_query()
158+
query = builder.chain_or(builder.contains('subject', 'george best'), builder.startswith('subject', 'quotes') # see Query object in Utils
157159
messages = mailbox.get_messages(limit=25, query=query)
158160
159161
message = messages[0] # get the first one

docs/latest/_sources/usage/utils/query.rst.txt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@ For example:
1212

1313
.. code-block:: python
1414
15-
from O365.utils import QueryBuilder
16-
builder = QueryBuilder(protocol=account.protocol)
15+
builder = mailbox.new_query()
1716
1817
query = builder.chain_or(builder.contains('subject', 'george best'), builder.startswith('subject', 'quotes')
1918
@@ -27,7 +26,7 @@ For example:
2726
# contains(subject, 'george best') or startswith(subject, 'quotes') and createdDateTime gt '2018-03-21T00:00:00Z'
2827
# note you can pass naive datetimes and those will be converted to you local timezone and then send to the api as UTC in iso8601 format
2928
30-
# To use Query objetcs just pass it to the query parameter:
29+
# To use Query objects just pass it to the query parameter:
3130
filtered_messages = mailbox.get_messages(query=query)
3231
3332
You can also specify specific data to be retrieved with "select":

docs/latest/_sources/usage/utils/utils.rst.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,14 +49,14 @@ For example:
4949

5050
.. code-block:: python
5151
52-
query = mailbox.new_query() # you can use the shorthand: mailbox.q()
52+
builder = mailbox.new_query() # you can use the shorthand: mailbox.q()
5353
54-
query = query.on_attribute('subject').contains('george best').chain('or').startswith('quotes')
54+
query = builder.chain_or(builder.contains('subject', 'george best'), builder.startswith('subject', 'quotes')
5555
5656
# 'created_date_time' will automatically be converted to the protocol casing.
5757
# For example when using MS Graph this will become 'createdDateTime'.
5858
59-
query = query.chain('and').on_attribute('created_date_time').greater(datetime(2018, 3, 21))
59+
query = query & builder.greater('created_date_time', datetime(2018, 3, 21))
6060
6161
print(query)
6262

docs/latest/api/utils/token.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,7 @@ <h1>Token<a class="headerlink" href="#token" title="Link to this heading"></a
444444

445445
<dl class="py attribute">
446446
<dt class="sig sig-object py" id="O365.utils.token.BaseTokenBackend.serializer">
447-
<span class="sig-name descname"><span class="pre">serializer</span></span><em class="property"><span class="w"> </span><span class="p"><span class="pre">=</span></span><span class="w"> </span><span class="pre">&lt;module</span> <span class="pre">'json'</span> <span class="pre">from</span> <span class="pre">'/opt/hostedtoolcache/Python/3.13.7/x64/lib/python3.13/json/__init__.py'&gt;</span></em><a class="headerlink" href="#O365.utils.token.BaseTokenBackend.serializer" title="Link to this definition"></a></dt>
447+
<span class="sig-name descname"><span class="pre">serializer</span></span><em class="property"><span class="w"> </span><span class="p"><span class="pre">=</span></span><span class="w"> </span><span class="pre">&lt;module</span> <span class="pre">'json'</span> <span class="pre">from</span> <span class="pre">'/opt/hostedtoolcache/Python/3.14.0/x64/lib/python3.14/json/__init__.py'&gt;</span></em><a class="headerlink" href="#O365.utils.token.BaseTokenBackend.serializer" title="Link to this definition"></a></dt>
448448
<dd></dd></dl>
449449

450450
</dd></dl>

docs/latest/getting_started.html

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -145,13 +145,13 @@ <h2>Basic Usage<a class="headerlink" href="#basic-usage" title="Link to this hea
145145
<p>The first step to be able to work with this library is to register an application and retrieve the auth token. See <a class="reference internal" href="#authentication"><span class="std std-ref">Authentication</span></a>.</p>
146146
<p>With the access token retrieved and stored you will be able to perform api calls to the service.</p>
147147
<p>A common pattern to check for authentication and use the library is this one:</p>
148-
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">scopes</span> <span class="o">=</span> <span class="p">[</span><span class="s1">&#39;my_required_scopes&#39;</span><span class="p">]</span> <span class="c1"># you can use scope helpers here (see Permissions and Scopes section)</span>
148+
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">requested_scopes</span> <span class="o">=</span> <span class="p">[</span><span class="s1">&#39;my_required_scopes&#39;</span><span class="p">]</span> <span class="c1"># you can use scope helpers here (see Permissions and Scopes section)</span>
149149

150150
<span class="n">account</span> <span class="o">=</span> <span class="n">Account</span><span class="p">(</span><span class="n">credentials</span><span class="p">)</span>
151151

152152
<span class="k">if</span> <span class="ow">not</span> <span class="n">account</span><span class="o">.</span><span class="n">is_authenticated</span><span class="p">:</span> <span class="c1"># will check if there is a token and has not expired</span>
153153
<span class="c1"># ask for a login using console based authentication. See Authentication for other flows</span>
154-
<span class="k">if</span> <span class="n">account</span><span class="o">.</span><span class="n">authenticate</span><span class="p">(</span><span class="n">scopes</span><span class="o">=</span><span class="n">scopes</span><span class="p">)</span> <span class="ow">is</span> <span class="kc">False</span><span class="p">:</span>
154+
<span class="k">if</span> <span class="n">account</span><span class="o">.</span><span class="n">authenticate</span><span class="p">(</span><span class="n">requested_scopes</span><span class="o">=</span><span class="n">requeated_scopes</span><span class="p">)</span> <span class="ow">is</span> <span class="kc">False</span><span class="p">:</span>
155155
<span class="k">raise</span> <span class="ne">RuntimeError</span><span class="p">(</span><span class="s1">&#39;Authentication Failed&#39;</span><span class="p">)</span>
156156

157157
<span class="c1"># now we are authenticated</span>
@@ -345,7 +345,7 @@ <h3>Examples<a class="headerlink" href="#examples" title="Link to this heading">
345345
<span class="c1"># the default authentication method will be &quot;on behalf of a user&quot;</span>
346346

347347
<span class="n">account</span> <span class="o">=</span> <span class="n">Account</span><span class="p">(</span><span class="n">credentials</span><span class="p">)</span>
348-
<span class="k">if</span> <span class="n">account</span><span class="o">.</span><span class="n">authenticate</span><span class="p">(</span><span class="n">scopes</span><span class="o">=</span><span class="p">[</span><span class="s1">&#39;basic&#39;</span><span class="p">,</span> <span class="s1">&#39;message_all&#39;</span><span class="p">]):</span>
348+
<span class="k">if</span> <span class="n">account</span><span class="o">.</span><span class="n">authenticate</span><span class="p">(</span><span class="n">requested_scopes</span><span class="o">=</span><span class="p">[</span><span class="s1">&#39;basic&#39;</span><span class="p">,</span> <span class="s1">&#39;message_all&#39;</span><span class="p">]):</span>
349349
<span class="nb">print</span><span class="p">(</span><span class="s1">&#39;Authenticated!&#39;</span><span class="p">)</span>
350350

351351
<span class="c1"># &#39;basic&#39; adds: &#39;https://graph.microsoft.com/User.Read&#39;</span>
@@ -395,7 +395,7 @@ <h3>Examples<a class="headerlink" href="#examples" title="Link to this heading">
395395
<li><p>Console based authentication interface:</p>
396396
<p>You can authenticate using a console. The best way to achieve this is by using the authenticate method of the Account class.</p>
397397
<p>account = Account(credentials)
398-
account.authenticate(scopes=[‘basic’, ‘message_all’])
398+
account.authenticate(requested_scopes=[‘basic’, ‘message_all’])
399399
The authenticate method will print into the console an url that you will have to visit to achieve authentication. Then after visiting the link and authenticate you will have to paste back the resulting url into the console. The method will return True and print a message if it was succesful.</p>
400400
<p><strong>Tip:</strong> When using macOS the console is limited to 1024 characters. If your url has multiple scopes it can exceed this limit. To solve this. Just import readline at the top of your script.</p>
401401
</li>
@@ -480,14 +480,14 @@ <h3>Scopes<a class="headerlink" href="#scopes" title="Link to this heading"><
480480

481481
<span class="n">credentials</span> <span class="o">=</span> <span class="p">(</span><span class="s1">&#39;client_id&#39;</span><span class="p">,</span> <span class="s1">&#39;client_secret&#39;</span><span class="p">)</span>
482482

483-
<span class="n">scopes</span> <span class="o">=</span> <span class="p">[</span><span class="s1">&#39;Mail.ReadWrite&#39;</span><span class="p">,</span> <span class="s1">&#39;Mail.Send&#39;</span><span class="p">]</span>
483+
<span class="n">requested_scopes</span> <span class="o">=</span> <span class="p">[</span><span class="s1">&#39;Mail.ReadWrite&#39;</span><span class="p">,</span> <span class="s1">&#39;Mail.Send&#39;</span><span class="p">]</span>
484484

485-
<span class="n">account</span> <span class="o">=</span> <span class="n">Account</span><span class="p">(</span><span class="n">credentials</span><span class="p">,</span> <span class="n">scopes</span><span class="o">=</span><span class="n">scopes</span><span class="p">)</span>
485+
<span class="n">account</span> <span class="o">=</span> <span class="n">Account</span><span class="p">(</span><span class="n">credentials</span><span class="p">,</span> <span class="n">requested_scopes</span><span class="o">=</span><span class="n">requested_scopes</span><span class="p">)</span>
486486
<span class="n">account</span><span class="o">.</span><span class="n">authenticate</span><span class="p">()</span>
487487

488488
<span class="c1"># The latter is exactly the same as passing scopes to the authenticate method like so:</span>
489489
<span class="c1"># account = Account(credentials)</span>
490-
<span class="c1"># account.authenticate(scopes=scopes)</span>
490+
<span class="c1"># account.authenticate(requested_scopes=requested_scopes)</span>
491491
</pre></div>
492492
</div>
493493
<p>Scope implementation depends on the protocol used. So by using protocol data you can automatically set the scopes needed. This is implemented by using ‘scope helpers’. Those are little helpers that group scope functionality and abstract the protocol used.</p>
@@ -578,7 +578,7 @@ <h3>Scopes<a class="headerlink" href="#scopes" title="Link to this heading"><
578578
<span class="n">scopes_graph</span> <span class="o">=</span> <span class="n">protocol</span><span class="o">.</span><span class="n">get_scopes_for</span><span class="p">(</span><span class="s1">&#39;message_all&#39;</span><span class="p">)</span>
579579
<span class="c1"># scopes here are: [&#39;https://graph.microsoft.com/Mail.ReadWrite&#39;, &#39;https://graph.microsoft.com/Mail.Send&#39;]</span>
580580

581-
<span class="n">account</span> <span class="o">=</span> <span class="n">Account</span><span class="p">(</span><span class="n">credentials</span><span class="p">,</span> <span class="n">scopes</span><span class="o">=</span><span class="n">scopes_graph</span><span class="p">)</span>
581+
<span class="n">account</span> <span class="o">=</span> <span class="n">Account</span><span class="p">(</span><span class="n">credentials</span><span class="p">,</span> <span class="n">requested_scopes</span><span class="o">=</span><span class="n">scopes_graph</span><span class="p">)</span>
582582
</pre></div>
583583
</div>
584584
<div class="admonition note">

docs/latest/searchindex.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)