@@ -99,6 +99,20 @@ def api_endpoint(self, url):
9999 f"{ self .config ['resource' ]} { self .config ['api_version' ]} /" ,
100100 url .lstrip ('/' ))
101101
102+ def get (self , endpoint , headers = None , stream = False ):
103+ """GET from API (authenticated with access token)."""
104+
105+ self .token_validation ()
106+
107+ # merge passed headers with default headers
108+ merged_headers = self .headers ()
109+ if headers :
110+ merged_headers .update (headers )
111+
112+ return requests .get (self .api_endpoint (endpoint ),
113+ headers = merged_headers ,
114+ stream = stream )
115+
102116 def headers (self , headers = None ):
103117 """Returns dictionary of default HTTP headers for calls to Microsoft Graph API,
104118 including access token and a unique client-request-id.
@@ -153,6 +167,26 @@ def logout(self, redirect_to=None):
153167 if redirect_to :
154168 bottle .redirect (redirect_to )
155169
170+ def post (self , endpoint , headers = None , data = None , verify = False , params = None ):
171+ """POST to API (authenticated with access token).
172+
173+ headers = custom HTTP headers (merged with defaults, including access token)
174+
175+ verify = the Requests option for verifying SSL certificate; defaults
176+ to False for demo purposes. For more information see:
177+ http://docs.python-requests.org/en/master/user/advanced/#ssl-cert-verification
178+ """
179+
180+ self .token_validation ()
181+
182+ merged_headers = self .headers ()
183+ if headers :
184+ merged_headers .update (headers )
185+
186+ return requests .post (self .api_endpoint (endpoint ),
187+ headers = merged_headers , data = data ,
188+ verify = verify , params = params )
189+
156190 def redirect_uri_handler (self ):
157191 """Redirect URL handler for AuthCode workflow. Uses the authorization
158192 code received from auth endpoint to call the token endpoint and obtain
0 commit comments