在python上为Oauth2设置安全https连接

在python上为Oauth2设置安全https连接,python,python-3.x,https,oauth-2.0,python-requests,Python,Python 3.x,Https,Oauth 2.0,Python Requests,我正在尝试使用google people API在我们的工作手机上自动创建一些联系人。但是为了使用people API,我需要使用OAuth 2,并且我正在使用以下代码。我转到授权URL,获取授权响应,但当我运行令牌行时,我得到错误: InsecureTransportError: (insecure_transport) OAuth 2 MUST utilize https. 代码如下: import json with open(r'C:\Users\Pedro\Desktop\clien

我正在尝试使用google people API在我们的工作手机上自动创建一些联系人。但是为了使用people API,我需要使用OAuth 2,并且我正在使用以下代码。我转到授权URL,获取授权响应,但当我运行令牌行时,我得到错误:

InsecureTransportError: (insecure_transport) OAuth 2 MUST utilize https.
代码如下:

import json
with open(r'C:\Users\Pedro\Desktop\client_id.json') as abb:
    ab = json.load(abb)



client_id = ab['installed']['client_id']
redirect_uri = ab['installed']['redirect_uris'][0]
client_secret = ab['installed']['client_secret']

from requests_oauthlib import OAuth2Session


scope = ['https://www.googleapis.com/auth/contacts']
oauth = OAuth2Session(client_id, redirect_uri=redirect_uri,
                          scope=scope)
authorization_url, state = oauth.authorization_url(
        'https://accounts.google.com/o/oauth2/auth',
        # access_type and prompt are Google specific extra
        # parameters.
        access_type="offline", prompt="select_account")

#authorization_response = input('Enter the full callback URL')
authorization_response = r'RESPONSE'


token = oauth.fetch_token(
        'https://accounts.google.com/o/oauth2/token',
        authorization_response=authorization_response,
        # Google specific extra parameter used for client
        # authentication
        client_secret=client_secret,
        )

我想我需要做的就是设置一个https服务器?但是我试图找到OAuth2服务器的例子,我得到的只是人们告诉我禁用测试需求。我不想测试,我想运行OAuth,以便在people API上调用请求。

尝试在终端中拍摄
导出OAUTHLIB\u unsecure\u TRANSPORT=1
。它应该会起作用