ValueError: Protocol not provided to Api Component
See original GitHub issueHi,
I’ve trouble initializing Calendar
or Schedule
object.
It throws me an error: ValueError: Protocol not provided to Api Component
I follow your documentation and example but it uses Account for authentication and account.schedule to get schedule data. but problem with Account is that it print the url and then user needs to paste it in browser and copy the resultant url to console. So it is not suitable for what i am trying to achive.
I am trying to achive it through the web based authentication. I already have one web app where i want to integrate the calendar and events. So i am using Flask
and want to do it web based. So There are two end points:
- /api/O365api - For authentication and redirecting to my other end point (2) if success
- /api/GetCode - This method is where i want to get the appropriate calender/schedule object and further getting events etc.
Below is my code:
from O365 import Connection
from O365 import Calendar, Schedule, MSGraphProtocol
from O365.utils import ApiComponent
import datetime as dt
from O365 import oauth_authentication_flow
from flask import Blueprint
from flask import redirect, request
outlookApi = Blueprint('outlook_api', __name__)
appid = 'MYAPPID'
clientSecret = 'MYAPPSECRET'
credentials = (appid, clientSecret)
scopes = ['https://graph.microsoft.com/Calendars.Read']
def redirectToMs(url):
return redirect(url, code=302)
@outlookApi.route("/api/O365api")
def O365Api():
global con
con = Connection(credentials, scopes=scopes)
url = con.get_authorization_url(scopes, redirect_uri="http://localhost:31544/api/GetCode")
return redirectToMs(url)
@outlookApi.route("/api/GetCode")
def GetCode():
val = request.url
result = con.request_token(val)
if result:
print('Authentication Flow Completed. Oauth Access Token Stored. '
'You can now use the API.')
# s = Schedule() ## Even this is also not working and trhwoing same exception
c = Calendar() ## This line throws the exception
q = c.new_query('start').greater_equal(dt.datetime(2018, 5, 20))
q.chain('and').on_attribute('end').less_equal(dt.datetime(2018, 5, 24))
birthdays = c.get_events(query=q,
include_recurring=True)
for event in birthdays:
print(event.subject)
else:
print('Something go wrong. Please try again.')
return 'Success'
Issue Analytics
- State:
- Created 4 years ago
- Comments:15 (9 by maintainers)
Top Results From Across the Web
ValueError: Protocol not provided to Api Component trying to ...
I'm getting "ValueError: Protocol not provided to Api Component" while trying to send an email through the O365 package. My code is:
Read more >Source code for O365.connection
UTC or str timezone: preferred timezone, defaults to the system timezone :raises ValueError: if protocol_url or api_version are not supplied """ if ...
Read more >Valueerror Protocol Not Provided To Api Component
This is caused by lack of embedder support for Workers. That protocol documents may not provided under which api changes to how do...
Read more >O365 - PyPI
Microsoft Graph and Office 365 API made easy. ... to communicate with the api provider self.con = parent.con if parent else con protocol...
Read more >Connecting to Microsoft 365 using Python - HacWare Resources
The ultimate goal is to create a script that connects to the Microsoft O365 API. Getting Started. Before I started writing the script...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Do you have a database?
If yes:
If no:
The O365 library will obtain a token:
All this works automatically. You just have to define the TokenBackend.
You can check if there is a token stored in the TokenBackend and if this token is valid with
account.is_authenticated
property.I think this is the most I can help you.
@softsan Check Different Authentication Flows