Skip to content

ckrintz/Observant-OpenLink

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Observant-OpenLink

This program performs the OAuth2 handshake to obtain authorization from a user interested in sharing their Observant data with this app via the Observant Openlink API. Our goal is to provide developers with a Python example similar to the Java example provided by Observant. The code is not production-quality or secure (we store the secret and access token in plain text files), but it provides a starting point for writing a service that interacts with the Observant API.

In order to use the program, you must contact Observant to get permission (and the client secret, test-user login, and test-user password) to access their test facility. Place the client secret value in creds.json for the key 'secret'. Use the login and password when prompted to do so during the OAuth2 process. Keeping everything else unchanged (including the required redirect URL), this program should work for you out of the box. Improvements and suggestions are welcomed!

The program uses

Run the program via python ObsServ.py. And direct your browser to the server (http://localhost:9977/). The initial handshake takes a few seconds to perform all of the redirects, so be patient. More details can be found in the code concerning one work around required for Basic Auth credentials/access

To register a client with Observant you email Jon Havey and send him your preferred

  • client\_id, e.g. MyFarmClient
  • and redirect urls (http, https, static IP and localhost, port, and route, e.g. http://XXX.XXX.XXX.XXX:9977/myfarm/oada, https://XXX.XXX.XXX.XXX:9977/myfarm/oada, http://localhost:9977/myfarm/oada, https://localhost:9977/myfarm/oada
  • He will send you the client secret in return. Once you receive this you can test against the IP-based redirects by setting up your server at that IP and running the program via python ObsServ.py prod. You should plug whichever redirect you are testing into redir=... in main in the production setting.

There is also a command line version you can use. This version gives you a URL to place in your browser so that you can manually retrieve the authorization code.

  • Generate and store the access tokens:
    python ObsServ_CLI.py
  • Use stored access tokens to query the test service (Watermark sensor):
    python ObsServ_CLI.py -r -n
  • Use stored access tokens (or generate them) to query the test service (Watermark sensor):
    python ObsServ_CLI.py -r

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages