How to use "import oauth2" in Google App Engine? - python

I want to use Tumblr's API v2, which includes OAuth. so I need to find a OAuth module.
I am supposed to use it like this:
import oauth2 as oauth
I have found the oauth2 source code here: https://github.com/simplegeo/python-oauth2
If I want to use it in my Linux Ubuntu 10.08, whats the process? I have installed git. I notice that there is a "setup.py", so I just have to run it? The ReadME https://github.com/simplegeo/python-oauth2/blob/master/README.md doesnt mention how to install, maybe it is too newbie.
If I want to use it in Google App Engine, how can I do it?
Thanks for your help. I am pretty new to GIT stuff.

On Ubuntu, simply sudo apt-get install python-oauth2 and the package will be installed for you automatically.
For AppEngine, you might take a look at the Google API Python Client's appengine examples. They have an OAuth2 client specifically designed to work with AppEngine.

Related

How do I connect to an external Oracle database using the Python cx_Oracle package on Google App Engine Flex?

My Python App Engine Flex application needs to connect to an external Oracle database. Currently I'm using the cx_Oracle Python package which requires me to install the Oracle Instant Client.
I have successfully run this locally (on macOS) by following the Instant Client installation steps. The steps required me to do the following:
Make a directory called /opt/oracle
Create a symlink from /opt/oracle/instantclient_12_2/libclntsh.dylib.12.1 to ~/lib/
However, I am confused about how to do the same thing in App Engine Flex (instructions). Specifically, here's what I'm confused about:
The instructions say I should run sudo yum install libaio to install the libaio package. How do I do this on GAE Flex? Or is this package already available?
I think I can add the Instant Client files to GAE (a whopping ~100MB!), then set the LD_LIBRARY_PATH environment variable in app.yaml to export LD_LIBRARY_PATH=/opt/oracle/instantclient_12_2:$LD_LIBRARY_PATH. Will this work?
Is this even feasible without using custom Docker containers on App Engine Flex?
Overall I'm not sure if I'm on the right track. Would love to hear from someone who has managed this before :)
If any of your dependencies is not available in the base GAE flex images provided by Google and cannot be installed via pip (because it's not a python package or it's not available in PyPI or whatever other reason) then you can't use the requirements.txt file to get it installed in your GAE flex app.
The proper way to satisfy such dependencies would be to build your own custom runtime. From About Custom Runtimes:
Custom runtimes allow you to define new runtime environments, which
might include additional components like language interpreters or
application servers.
Yes, that means providing a custom Docker file. In your particular case you'd be installing the Instant Client and libaio inside this Dockerfile. See also Building Custom Runtimes.
Answering your first question, I think that the instructions in the oracle website just show that you have to install said library for your application to work.
In the case of App engine flex, they way to ensure that the libraries are present in the deployment is with the requirements.txt textfile. There is a documentation page which does explain how to do so.
On the other hand, I will assume that "Instant Client Files" are not libraries, but necessary data for your App to run. You should use Google Cloud Storage to serve them, or any other alternative of Storage within Google Cloud.
I believe that, if this is all what you need for your App to work, pushing your own custom container should not be necessary.

Workarounds to get Google sign-in functioning with Python 2.6 and pyOpenSSL 0.10-2

I'm trying to get Google sign-in working using their Python API but the server I'm on (4UHosting) has Python 2.6 and pyOpenSSL 0.10-2 (5-years old).
This means that the API's call to OpenSSL.crypto.verify() fails as it doesn't exist in this version.
I can't install these myself, even --self as they require compiler use which I don't have. The admins are reluctant to install any updates that are not vetted. They won't install pyOpenSSL or Python 2.7 locally just for me. I can't find documentation from pyOpenSSL 0.10-2 that would have an equivalent function to verify().
I'm looking for some suggestions as where to head from here.
Any suggestions would be greatly appreciated,
Cyrille
A few ideas:
You could directly make your API calls to the Google API Endpoints instead of using the Python client library, for example, the token info endpoint can be used to verify tokens
You could do sign-in operations client-side and transfer data to your server once a session is attached
You could use another language (e.g. Ruby) for the sign-in operations

Python - Configure gevent library on Google App Engine

I'm newbie in programming and need some help in the following situation.
I want to use gevent library on Google App Engine. I'm writing in Python using webapp2.
So the question is how to configure it so that it will work with GAE SDK.
I've put gevent library files in my projects directory like other libraries which are working well in this project. But when I run my app on local server it says:
ImportError: No module named greenlet
I've installed it on my computer,
pip install greenlet -t way/to/python/lib/directory
still it doesn't work
I had similar problem with lxml library, but It was solved after I've written its name in app.yaml. But lxml is preinstalled on GAE as written here. Although it's not the case with gevent.
I would appreciate any help. Thanks!

oauth2 in GAE with python

I want to use a library which it use oauth2. Unfortunatelly, Google app engine cannot find oauth2 as a library.
When I browse my project I have the following error
import oauth2 as oauth
ImportError: No module named oauth2
I cannot use the oauth of google app engine, because I have to change the whole library.
Any advice how I can make oauth2 works on GAE?
The library use this version of oauth2 enter link description here
Ok you have to install the package first. It will install to your default python library. There are 3 ways to do this:
First way (MAC):
sudo easy_install oauth2
Second Way:
pip install oauth2
Third way (If you want to have more control over install location):
Download the zip file from here https://github.com/simplegeo/python-oauth2/archive/master.zip
Then unzip the file and navigate to the folder where it downloaded to.
Run
python3 setup.py
or
python setup.py
Depending on which package you'd like (python3 or 2)

How to implement WSGIProxy using setuptools in python google app engine for a webapp

Can somebody explain me how to use the setuptools inside python in google app engine to implement WSGIProxy for a webapp.
How do i utilize it, if i dont have access to the filesystem? Specifically,easy steps on how install package from python egg on GAE.
This should be relatively easy for someone who has used setuptools or installed 3rd party packages on GAE python.
I just answered almost the same question, but about a different library. The concept behind installing thirdparty libraries is exactly the same though, you need to either put a copy of the actual code in your app folder, or use a softlink to in.
GAE - Including external python modules without adding them to the repository?

Categories