Using web APIs with limited website access (raspberry pi) - python

I'm using a raspberry pi as a server to host a program. Part of what this program does is interface with websites such as spotify, google sheets, and google forms through their respective APIs (or a library wrapper)
In order to interface with spotify, i've attempted to use a python module called 'spotipy' which is a wrapper for the spotify API. However, i'm having trouble getting it to work, and I have a feeling its because the API requires authentication which utilizes the systems browser, i.e. chromium on the pi, but chromium does not have support for open.spotify.com due to its limited capabilities.
Is it reasonable to say that a web API wont work without access to the website you are attempting to interface with?
Hopefully this is provides enough information, thanks.

github.com/plamere/spotipy#quick-start
to answer your question, you don't need chromium to use APIs. According to the quickstart that I linked above
you need to register your raspberry pi as an App on spotify dev site and acquire the "credentials"
then declare those credentials in your script

Related

Azure IoT cloud-to-device messaging via Rails?

I'm currently building an API in Rails to control devices registered with an Azure IoT Hub.
Now, in the Azure documentation, I only see Python/Node/.Net guides to control the end devices.
I require Rails for certain libraries, and hence used it to build my API. But now I've hit this road block.
Is there no way I can send cloud-to-device messages? I don't see any official Rails support. I only require c2d messaging.
Edit : The only other way I can think of with my limited knowledge is to deploy a small Python/Flask app on the same server and have my Rails code make HTTP requests to it. Is this a bad approach?
I do recommend to use the Azure HttpTrigger Function for your solutions as an API integrator/mediator.

How to use Firebase with a linux based client app for bidirectional messages communication with server

I've seen Google's documentation and a lot of examples over the internet about how to use Firebase within Android / iOS applications, but I want to develop a client Firebase application which runs on a linux machine.
My requirements are:
Client runs on linux environment (either writtern in C++ or python).
Server is written in Javascript (NodeJS).
Server and client should have bi-directional communication between them using firebase realtime database.
I've seen also the firebase REST api, but I assume that is not good enough for me since I haven't seen a client listener api that listens on a something like onValueChanged.
Question:
How can I implement a linux-based app in C++ or python that listens to messages from server (data changes) using a listener, without having to call some get function each and every few seconds (just like NodeJS have the ref.on("child_changed",...) or ref.on("value",...)?
Help is much appreciated!
Unfortunately there is not official library for Realtime Database in Python but there are some third party wrappers around REST API.
Specifically I would look at Pyrebase library which also supports listening to live changes https://github.com/thisbejim/Pyrebase#streaming
For more information, libraries or other languages look at this page https://firebase.google.com/docs/database/rest/start
Google offers a C++ SDK you can download it here.
There is also a tutorial on the bottom of the page, but if you really want to dig into some code, here is the quickstart code on github from google with examples for each category on Firebase.
Google has also implemented a Game for demonstration purposes in C++ for Desktop OSs. here There you can find more advanced features and code samples.
I have only tried it with an XCode project on Mac OS X, and it works fine. I have no code for real time database but you should find the sample project in the github repo. https://github.com/firebase/quickstart-cpp
I hope this helps!
Greetings.
Haven't you try to use a Realtime Database triggers for C++ (that's is currently on beta) that allows you to simulate the same workflow as on JS?
From my point of view, it is the best way to get it to work as you want.
https://firebase.google.com/docs/functions/database-events

Sending emails using outlook with Python - Overcoming Azure Information Protection Classifications

I am using win32com to create emails, but with Azure Information Protection now enabled how do I select the classification from within python.
I have 2 solutions so far: turn off AIP or manually select the classification, is there any way to automate it from the script?
Thanks!
I suppose you are running the python script to create emails on the azure web app. As I know , azure web app runs in a sandbox. I searched the General Sandbox Restrictions from this doc and found the restrictions of COM servers as below:
Windows Servers have a bunch of COM servers configured and available
for consumption by default; however the sandbox prevents access to all
out-of-proc COM servers. For example, a sandboxed application cannot
call into WMI, or into MSIServer.
So, in fact, we could use Azure SendGrid Service to post emails instead of win32corn.
This is Azure SendGrid Python SDK and Azure SendGrid pricing rules.
Hope it helps you.

Quickbooks Desktop how to integrate with Python

I am trying to communicate with the QuickBooks Desktop Application using the Quick Books Web Connector (must be done in Python). I am not very familiar with SOAP- I was wondering whether anyone had a template/guide for communicating with the QBWC. I have read QuickBooks Web Connector Program Guide but there was no sample Python code.
The only requirement for which language to use with the Web Connector is to have a functioning SOAP server. From the Programmer's Guide:
What Platforms and Languages can I use in my Implementation?
The web service should be able to run on any platform that supports standard SOAP for communication. Platforms that are known to work include Apache Tomcat (Axis)and ASP (.Net).
As long as you can roll a WSDL-first SOAP server in Python, you can interface with the Web Connector. Unfortunately, it appears that might be a significant hurdle. Check out this question for suggestions on possible ways to accomplish that.
Once you get that working, the QuickBooks SDK provides bare-bones examples of a functioning web service. That should provide a sufficient template/guide for you to successfully interface with QuickBooks through the Web Connector.

Python access webcam and audio input

Can a python script on my server access the webcam and audio input of a user as easily and as well as a Flash plugin can?
No: the "plugin" you mention runs in the user's browser, your server-side script (Python or otherwise) runs on the server, a completely different proposition. This relates to your other recent question about a server-side script accessing information on your desktop: your client machine tends to be very protected against possibly malicious server-side apps (never enough, but everybody keeps trying to make it more and more protected these days).
Server-side web scripts have no access to the client other than through requests. You need to use JavaScript, Java, or Flash to access devices that the browser (and consequently user) allows them to.
Not as easy, no. But there are extensions you can use. E.g.
A Win32 Python Extension for Accessing Video Devices (e.g. a USB WebCam, a TV-Card, ...)
http://videocapture.sourceforge.net/
Tutorial:
http://technobabbler.com/?p=22

Categories