-
Notifications
You must be signed in to change notification settings - Fork 44
Fix/post requests #41
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 14 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
edd5665
Fix post requests
jobala 9e18bed
Decorate http methods with _get_middleware_options
jobala 342b15a
Add _get_middleware_options decorator to middleware_control.py
jobala fc4f88b
Use _get_middleware_options decorator
jobala 53b4a52
Get middleware options from middleware_control singleton
jobala 84eeed3
Stops attaching the middleware control, it is no longer necessary
jobala c51407c
Use correct type for scopes
jobala 131f4c0
Add samples
jobala 70a8191
Add placeholder email in sample
jobala cedaea4
Document graph_session.py and constants.py
jobala 0d22012
Document middleware
jobala 5388f83
Document MiddlewareControl
jobala ae37c11
Document _reset_middleware_options
jobala 0bab933
Merge branch 'dev' into fix/post-requests
jobala a1e09f6
Add review suggestions
jobala 4aa3c84
Merge remote-tracking branch 'origin/fix/post-requests' into fix/post…
jobala File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
|
||
class AuthMiddlewareOptions: | ||
def __init__(self, scopes: str): | ||
def __init__(self, scopes: [str]): | ||
self.scopes = scopes | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import json | ||
from pprint import pprint | ||
|
||
from azure.identity import InteractiveBrowserCredential | ||
jobala marked this conversation as resolved.
Show resolved
Hide resolved
|
||
from msgraphcore.middleware.authorization import TokenCredentialAuthProvider | ||
|
||
from msgraphcore import GraphSession | ||
|
||
browser_credential = InteractiveBrowserCredential(client_id='ENTER_YOUR_CLIENT_ID') | ||
auth_provider = TokenCredentialAuthProvider(browser_credential) | ||
graph_session = GraphSession(auth_provider) | ||
|
||
|
||
def post_sample(): | ||
body = { | ||
'message': { | ||
'subject': 'Python SDK Meet for lunch?', | ||
'body': { | ||
'contentType': 'Text', | ||
'content': 'The new cafeteria is open.' | ||
}, | ||
'toRecipients': [ | ||
{ | ||
'emailAddress': { | ||
'address': 'ENTER_RECEPIENT_EMAIL_ADDRESS' | ||
} | ||
} | ||
]} | ||
} | ||
|
||
result = graph_session \ | ||
.post('/me/sendMail', | ||
data=json.dumps(body), | ||
scopes=['mail.send'], | ||
headers={'Content-Type': 'application/json'} | ||
) | ||
pprint(result.status_code) | ||
|
||
|
||
def get_sample(): | ||
result = graph_session.get('/me/messages', scopes=['mail.read']) | ||
pprint(result.json()) | ||
|
||
|
||
if __name__ == '__main__': | ||
post_sample() | ||
get_sample() | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.