googleidentitytoolkit(v3)与GAE/python沙盒兼容吗?

2024-09-26 22:12:05 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在为一个网站开发一个python GAE应用程序,并试图让联合登录在上面。在

根据Identity Platform choosing guide的说法,网站的最佳解决方案似乎是Google Identity Toolkit (web)。浏览了我能找到的所有相关文档,然后转到教程,在那里我遇到了一个问题—安装identity-toolkit-python-client包失败,出现了与一个cffi库相关的C编译错误,与此类似:

# python -m pip install identity-toolkit-python-client
...
gcc -pthread -fno-strict-aliasing -fmessage-length=0 -grecord-gcc-switches -O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector -funwind-tables -fasynchronous-unwind-tables -g -DNDEBUG -fmessage-length=0 -grecord-gcc-switches -O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector -funwind-tables -fasynchronous-unwind-tables -g -DOPENSSL_LOAD_CONF -fPIC -I/usr/include/python2.7 -c src/cryptography/hazmat/bindings/__pycache__/_Cryptography_cffi_a269d620xd5c405b7.c -o build/temp.linux-x86_64-2.7/src/cryptography/hazmat/bindings/__pycache__/_Cryptography_cffi_a269d620xd5c405b7.o

src/cryptography/hazmat/bindings/__pycache__/_Cryptography_cffi_a269d620xd5c405b7.c:2:20: fatal error: Python.h: No such file or directory

 #include <Python.h>

                    ^

compilation terminated.

error: command 'gcc' failed with exit status 1

在为我的linux发行版安装了一些特定的软件包之后,我终于成功地安装了这个软件包,但是这些失败导致了我的实际问题(这些教程非常通用,我没有发现任何关于GAE限制的提示)。在

GAE python sandbox documentation来看,GAE应用程序中只应存在纯python代码:

All code for the Python runtime environment must be pure Python, and not include any C extensions or other code that must be compiled.

我在gaesdk或其第三方库中没有看到identity工具包,据我所知,这意味着我必须在我自己的应用程序中使用install it as a 3rd party library。但是纯python代码限制也适用于这些lib:

You can add any third-party library to your application, as long as it is implemented in "pure Python" (no C extensions) and otherwise functions in the App Engine runtime environment.

因此标题中的问题。在

我错过什么了吗?在

谢谢。在

到目前为止,我使用的是webapp2和jinja2。在


Tags: src应用程序tablesincludeasbindingscffiidentity
3条回答

根据Identity Toolkit论坛上的this thread,您可以通过包含PyCryptoV2.6或更高版本在AppEngine沙盒中使用Identity Toolkit。在

为此,请将以下内容添加到应用程序yaml文件:

libraries:
- name: pycrypto
  version: 2.6

这并不是100%,支持第三方lib的PyCrypto、numpylxml都有基于C的扩展,但这些都是google直接支持的。你不能添加你自己不在名单上的。在

见第三方libs文件https://cloud.google.com/appengine/docs/python/tools/libraries27

你必须区分谷歌支持的“第三方库”和你自己提供的第三方库。在

你还没有说你使用的是什么框架。您可能会发现值得一看authomatic http://peterhudec.github.io/authomatic/

开箱即用支持:

  • OAuth 1.0a提供商:Bitbucket、Flickr、Meetup、Plurk、Twitter, Tumblr、UbuntuOne、Vimeo、Xero、Xing和Yahoo。OAuth 2.0提供程序: 亚马逊、Behance、Bitly、Cosm、DeviantART、Eventbrite、Facebook, Foursquare、GitHub、谷歌、LinkedIn、PayPal、Reddit、Viadeo、VK, WindowsLive、Yammer和Yandex。python openid和Google应用引擎 基于OpenID。在

经过一番挖掘,我终于有了进展。在

Tim Hofman和dsalama的回答都适用,但真正使天平倾斜的是这个答案:How to import lib folder within Modules这让我意识到第三方libs doc对于模块位于单独目录中的应用程序来说不是很好(典型的文档化应用程序结构https://cloud.google.com/appengine/docs/python/modules/#Python_Configuration

基本上,必须根据需要为使用第三方LIB的每个模块应用供应商方案:

  • 在每个模块目录中,lib目录(或libs本身,取决于所使用的供应商方案)必须是可见/可访问的
  • 每个模块都必须有自己的appengine_config.py文件,其中供应商代码与模块的.yaml文件并排可见,因为模块无权访问位于应用程序根目录中的文件(如果所选的供应商方案依赖于此类文件)

相关问题 更多 >

    热门问题