How to upload files to onedrive using msgraph-sdk-python? - python

I'm not a newbie when it comes to python (nor a professional), but this is the first time I'm trying something like this.
I would like to upload files to OneDrive using an python script. Sounds simple right? Well apparently it's more then I can handle.
From what I've seen so far the onedrive-sdk-python I was using apparently doesn't work anymore (source: https://github.com/OneDrive/onedrive-sdk-python/issues/119) because it's being decommissioned.
The new SDK to use is the one for Microsoft Graph I guess? But the github (https://github.com/MicrosoftArchive/msgraph-sdk-python) doesn't really mention how to set up the new Oauth2 authentication, get a token and use the client in python. The links mentioned in the authentication section don't work for me, I get error messages like: "AADSTS900144: The request body must contain the following parameter: 'client_id'."
I looked on stackoverflow for similar questions but most of them are about the old onedrive-sdk and the most recent one I could find was almost 3 months old. The response there was that it was still under development.
I guess the problems I've been having are all related to the Microsoft Graph still being in development, but I was wondering if someone managed to get it to work and if they could point me in the right direction to get the authentication setup and getting me started on uploading files to OneDrive.
Some details in case it matters:
Rasbian 9 Stretch
Python 2.7.13 & Python 3.5.3 (tried both)
OneDrive business account
Many thanks to anyone who can point me in the right direction :)

I'm afraid the SDK you're using is no longer being actively maintained. From the ReadMe:
This library is no longer actively supported. To integrate Microsoft Graph into your Python solution, we recommend using REST and taking a look at our new Python samples and documentation.
To answer your question on tokens, these are not technically issued by Microsoft Graph. They're issued by Azure Active Directory (or Outlook.com for personal accounts). You obtain a token using OAuth 2.0.
You are, however, on the right track. Before you can do anything with Microsoft Graph, you're going to need to obtain an OAuth token. The good news here is there's a sample Python project that walks you through how this process works: Python authentication samples for Microsoft Graph.

Related

FirebaseMessaging.getToken() using python

I'm building a kivy app and almost got firebase cloud messaging working using the pyfcm
package from pypi.
What i'm stuck on is how to get the "registration token" that the firebase SDK creates on app install so that i have a registration token to send push notifications to.
There seems to be lots of info scattered around the net in regards to doing it using some other language other than "python", but python is all i know so i'm trying to work it out for that language.Any one have tips on how i go about that please ?
I can't find a python package that has the FirebaseMessaging.getToken() in it which is what the firebase documentation keeps referring to, so i'm lost and my brain is going mushy now due to researching this for hours and hours so far :)
any help appreciated
To answer my own question.
For those wondering the same question as i had. I came across this package https://github.com/Fox520/pushyy
In that package the guy has incorporated the ability to get the device token and also update the token when it changes. It takes a little manipulating to get the package to work properly with the latest gradle version but it is do able.
There doesnt seem to be a direct "python" method as such to get the token so using this package makes use of the required java and python code to achieve the task. Using this and using pyfcm from pypi to send messages, i'm now able to send firebase push notifications from my kivy app :)

Send message to a kafka topic using java

After several weeks looking for some information here and google, I've decided to post it here to see if anyone with the same problem can raise me a hand.
I have a java application developed in Eclipse Ganymede using tomcat to connect with my local database. The problem is that I want to send a simple message ("Hello World") to a Kafka Topic published on a public server. I've imported the libraries and developed the Kafka function but something happens when I run in debug mode. I have no issues or visible errors when compiling, but when I run the application and push the button to raise this function it stops in KafkaProducer function because there is NoClassDefFoundError kafka.producer..... It seems like it is not finding the library properly, but I have seen that it is in the build path properly imported.
I am not sure if the problem is with Kafka and the compatibility with Eclipse or Java SDK (3.6), it could be?. Anyone knows the minimum required version of Java for Kafka?
Also, I have found that with Kafka is really used Scala but I want to know if I can use this Eclipse IDE version for not change this.
Another solution that I found is to use a Python script called from the Java application, but I have no way to call it from there since I follow several tutorials but then nothing works, but I have to continue on this because it seems an easier option. I have developed the .py script and works with the Kafka server, now I have to found the solution to exchange variables from Java and Python. If anyone knows any good tutorial for this, please, let me know.
After this resume of my days and after hitting my head with the walls, maybe someone has found this error previously and can help me to find the solution, I really appreciate it and sorry for the long history.
Please include the Kafka client library within the WAR file of the Java application which you are deploying to Tomcat
Please use org.apache.kafka.clients.producer.KafkaProducer rather than kafka.producer.Producer (which is the old client API) and make sure you have the Kafka client library on the classpath. The client library is entirely in Java. It's the old API that's written in scala, as is the server-side code. You don't need to import the server library in your code or add it to the classpath if you use the new client API.
At the end the problem was related with the library that was not well added. I had to add it in the build.xml file, importing here the library. Maybe this is useful for the people who use an old Eclipse version.
So now it finds the library but I have to update Java version, other matter. So it is solved

Deploying a python cloud service/webjob to Azure via GIT

I'm trying to find a way to bind my cloud service or webjob to GIT.
I've tried following this guide
Everything worked well - the files were uploaded and a build job was initiated on the server, BUT I keep getting the following error:
C:\a\src\AzureCloudService1\Crawler\Crawler.pyproj (48, 0) The
imported project "C:\Program Files
(x86)\MSBuild\Microsoft\VisualStudio\v12.0\Python
Tools\Microsoft.PythonTools.Worker.targets" was not found. Confirm
that the path in the declaration is correct, and that the
file exists on disk.
I've searched this problem and based on suggestions I've found I uploaded the missing files and changed the location that points to them.
The above missing files were then read successfully but they're trying to use other files as well, which can't be found for the same reason.
Shortly, I get a chain of "not found" files.
I'm out of ideas, will appreciate your help.
Your issue is little relationship with Azure Could Service deployment, it’s the limitation of VSO building process. The VSO uses MSBuild to check code and build project, and which is lack of python tools dependence on VSO server. Here is the same issue with you and explained by VSO engineer. I’d like to quote a paragraph of this communication:
VSO Build preview is going to be able to better support non-.NET projects, and explicit support for Python projects will come eventually but is already available through command-line options. Getting Cloud Service projects changed to work better is more difficult (I don't even have a good contact for that team right now). Our own team also has conflicted priorities, and right now we've got everyone focusing on fixing crashes and issues that affect most of our users - working around Cloud Service's lack of extensibility is one of the (many) things that gets pushed down the list.
Currently, we can publish Cloud Server to Azure directly in Visual Studio as a workaround.
For more details, please read Python web and worker roles with Python Tools 2.2 for Visual Studio

How can I control Google Hangouts with Python?

As a Python project, I would like to control Google Hangouts (start/end video/phone calls, mute/unmute, dial a key, etc) using Python 2.7; e.g. create a call() function that accepts email addresses and phone numbers of people in my circles/contacts and call those people.
As a newbie, however, I don't know whether:
There is already a Python package that does (most of) that,
I need to sign up for Google Cloud, install Google Cloud SDK, learn
how to use the Google App Engine, etc. or just being logged into Google in a browser is sufficient
So, I'd appreciate if someone could sketch a brief road map for me.
For example, what Python packages do I need?
Hangups, a python instant messaging client for hangouts already exists and is probably worth a look. It's a terminal client, but it is also used as a back-end for several GUI applications.
https://github.com/tdryer/hangups

Python Google Checkout Notification API

I am attempting to work with Google Checkout on Google App Engine. Currently, I am writing everything in Python and have the checkout process working. I am having some difficulty getting the notifications of processed orders functioning. I've been searching for Python examples, but thus far have been unsuccessful. Programming directly off of the documentation provided by Google, I have not been able to get my notifications working either. Would anyone happen to have a framework/demo Google Checkout Notification example in Python?
The chippyshop source has a nice example of a python Google Checkout implementation that should get you moving in the right direction.
UPDATE: I actually ended up needing to do this myself so I extended the example linked above and turned it into a reusable RequestHandler for use on GAE.
You can find the source and examples on github which should serve as a good starting point for any others following this path.

Categories

Resources