Page 1 of 1
Python Plugin: OAuth 2.0 to Access Google APIs
Posted: Tuesday 24 January 2017 13:53
by BakSeeDaa
I intend to make a Python Plugin for accessing a Google Calendar (private and public) in Domoticz. Google APIs use the OAuth 2.0 protocol for authentication and authorization.
The idea is that You create a new hardware type GCal (That is a Python Plugin), enter Calendar ID, Client ID, and Client Secret (Obtained from the Google API Console.) and click save.
Then there is a authentication step where the user logs in with their Google account. After logging in, the user is asked whether they are willing to grant the permissions that Domoticz is requesting. This process is called user consent. I need a way to initiate this process after the configuration details has been filled in. If I could have a button to click to initiate the user consent (a redirect will occur)
I have no idea if it's feasible or not.
@Dnpwwo, what do You think?
Re: Python Plugin: OAuth 2.0 to Access Google APIs
Posted: Tuesday 24 January 2017 21:52
by remb0
moved to python.
Re: Python Plugin: OAuth 2.0 to Access Google APIs
Posted: Tuesday 24 January 2017 22:34
by ayasystems
I have your idea implemented.... domoticz speech my calendar when the pir raise the signal in the morning
Chech the google example all is writen
https://developers.google.com/google-ap ... art/python
Ask me your doubs
Sorry my english is not very good
Re: Python Plugin: OAuth 2.0 to Access Google APIs
Posted: Wednesday 25 January 2017 9:16
by gizmocuz
I think there should be an option to also provide some javascript (logic) in the plugin setup
(Currently we have only parameters)
And a way to be able to call a function in the python script for configuration
I am facing a similar issue, i want to press a setup button that asks from my python script via an UDP broadcast what devices are there
Maybe one function with a parameter so we can use it many times
And if we can also have a <script></script> section in the setup, that would be great
Maybe add a 'Button' parameter with a function option, still when data is returned you need some logic
Or a default OAuth2 setup handler as this gets more common everyday (logitech harmony for example)
Re: Python Plugin: OAuth 2.0 to Access Google APIs
Posted: Wednesday 25 January 2017 10:46
by Dnpwwo
Couple of thoughts:
- We could certainly add to the XML definition. Depends how generic we wanted it to be. A button tag with associated action script would be easy or we could add a generic HTML section and people could go crazy doing anything they want
, I don't mind either way let me know what you prefer
- An OAuth2 provider is a good idea but would be some way off. Currently the framework supports HTTP (almost), it doesn't even support HTTPS yet. There are a number of protocols that could be supported, I'm currently looking at HNAP1 which someone in Greece has exposed to me running on a DLink DSP-W215 switch which is a SOAP based protocol
- The Hardware page calling back to plugin would be problematic, mainly because there is no guarantee that the plugin is running (the first time you configure it for example), would be easier to potentially send the plugin commands via Domoticz in the same way you can from Lua but via the web front end but with a response being returned. I guess understanding the use cases for this would help shape the solution.
Re: Python Plugin: OAuth 2.0 to Access Google APIs
Posted: Sunday 29 January 2017 10:31
by BakSeeDaa
gizmocuz wrote:...
Or a default OAuth2 setup handler as this gets more common everyday (logitech harmony for example)
Nice idea... Would that be independent of the Python Plugin? I believe it would open up many doors and the numbers of use cases are vast ...
Re: Python Plugin: OAuth 2.0 to Access Google APIs
Posted: Sunday 29 January 2017 10:36
by gizmocuz
The Hardware page calling back to plugin would be problematic, mainly because there is no guarantee that the plugin is running (the first time you configure it for example), would be easier to potentially send the plugin commands via Domoticz in the same way you can from Lua but via the web front end but with a response being returned. I guess understanding the use cases for this would help shape the solution.
If the plugin is found in the hardware page, it can be loaded.
If this function is 'static', not depending on the plugin, we might could use this ?
For example a button that will auto detect a UPNP device via a UDP broadcast and returns if found an IP address (or another object structure)
Re: Python Plugin: OAuth 2.0 to Access Google APIs
Posted: Monday 13 February 2017 19:27
by dynasticorpheus
BakSeeDaa wrote:gizmocuz wrote:...
Or a default OAuth2 setup handler as this gets more common everyday (logitech harmony for example)
Nice idea... Would that be independent of the Python Plugin? I believe it would open up many doors and the numbers of use cases are vast ...
I second that