Oauth 2.0 有没有一种方法可以自动授予GoogleAuth2权限

Oauth 2.0 有没有一种方法可以自动授予GoogleAuth2权限,oauth-2.0,google-spreadsheet-api,google-oauth,Oauth 2.0,Google Spreadsheet Api,Google Oauth,我们正在尝试使用使用oauth2.0身份验证的google电子表格api。我们使用google api文档中的以下代码进行oauth身份验证 def get_credentials(): CLIENT_SECRET_FILE = 'client_secret.json' SCOPES=[ 'https://www.googleapis.com/auth/spreadsheets' ] APPLICATION_NA

我们正在尝试使用使用oauth2.0身份验证的google电子表格api。我们使用google api文档中的以下代码进行oauth身份验证

def get_credentials():
        CLIENT_SECRET_FILE = 'client_secret.json'
        SCOPES=[
          'https://www.googleapis.com/auth/spreadsheets'
        ]
        APPLICATION_NAME = 'Knab'
        home_dir=os.path.expanduser('~')
        credential_dir=os.path.join(home_dir,'.credentials')
        if not os.path.exists(credential_dir):
            os.makedirs(credentials_dir)
        credential_path=os.path.join(credential_dir,'knab.json')
        store=oauth2client.file.Storage(credential_path)
        credentials=store.get()
        if not credentials or credentials.invalid:
            flow = client.flow_from_clientsecrets(CLIENT_SECRET_FILE,SCOPES)
            flow.user_agent=APPLICATION_NAME
            if flags:
                credentials=tools.run_flow(flow,store,flags)
            else:
                credentials=tools.run(flow,store)
        return credentials;

    credentials=get_credentials()
    http=credentials.authorize(httplib2.Http())
    discoveryUrl = ('https://sheets.googleapis.com/$discovery/rest?'
                        'version=v4')
    service = discovery.build('sheets', 'v4', http=http,
                                  discoveryServiceUrl=discoveryUrl)
我已经创建了oauth2密钥并传递了json文件(client_secret.json),一切都运行得很好,但是当我们在一个新的平台上运行代码时 机器,它要求我们打开一个谷歌链接和登录的凭据,并点击允许。我们将把亚马逊lambda作为 微服务。所以,不应该有人工干预。我尝试使用--noauth_local_webserver作为命令行参数运行。 它要求访问url并输入代码。我的想法是使用SSH连接另一台机器,运行selenium代码打开url并使用登录 我的google凭据,允许Permission并将代码返回到程序。我有个主意,但不知道如何实施,
欢迎您提出任何建议……

我建议您坚持谷歌文档上的内容。我相信谷歌有理由这样设置,主要是出于安全目的。这是为了避免预先编程的机器人或自动化行为。我建议坚持谷歌文档上的说明。我相信谷歌有理由这样设置,主要是出于安全目的。这是为了避免预先编程的机器人或自动化行为。