Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 31 additions & 1 deletion O365/directory.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,8 @@ def update_profile_photo(self, photo):
class Directory(ApiComponent):

_endpoints = {
'get_user': '/{email}'
'get_user': '/{email}',
"invitation": "invitations",
}
user_constructor = User #: :meta private:

Expand Down Expand Up @@ -473,3 +474,32 @@ def get_user_direct_reports(self, user, limit=100, *, query=None, order_by=None,
next_link=next_link, limit=limit)
else:
return direct_reports


def invite_user(self, email: str, redirect_url: str, **kwargs) -> dict[str]:
""" Sends a guest invitation to the named user to make them a guest of the tenant.
This user can then be added to groups and teams.

The return dict is what the graph call returns. The two key pieces of information
is the invitedUser > id key, and the inviteRedeemKey (which is used to activate
the account).


:param email: the email address of the guest to be added
:type email: str
:param redirect_url: the URL the user will be redirected to after registering their guest account
:type redirect_url: str
:rtype: dict
"""

url = self.build_url(self._endpoints.get('invitation'))
url = "{}{}".format( self.protocol.service_url, self._endpoints.get('invitation') )

data = kwargs
data['invitedUserEmailAddress'] = email
data['inviteRedirectUrl'] = redirect_url

response = self.con.post(url, data=data)

return_json = response.json()
return return_json
2 changes: 1 addition & 1 deletion docs/latest/api/utils/token.html
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@ <h1>Token<a class="headerlink" href="#token" title="Link to this heading"></a

<dl class="py attribute">
<dt class="sig sig-object py" id="O365.utils.token.BaseTokenBackend.serializer">
<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>
<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.2/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>
<dd></dd></dl>

</dd></dl>
Expand Down
2 changes: 1 addition & 1 deletion docs/latest/searchindex.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/source/overview.rst
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,6 @@ Rebuilding HTML Docs

.. code-block:: console

pip install sphinx
pip install sphinx sphinx-rtd-theme

* Run the shell script ``build_docs.sh``, or copy the command from the file when using on Windows
* Run the shell script ``build_docs.sh``, or copy the command from the file when using on Windows