<i id='Wj7U9'><tr id='Wj7U9'><dt id='Wj7U9'><q id='Wj7U9'><span id='Wj7U9'><b id='Wj7U9'><form id='Wj7U9'><ins id='Wj7U9'></ins><ul id='Wj7U9'></ul><sub id='Wj7U9'></sub></form><legend id='Wj7U9'></legend><bdo id='Wj7U9'><pre id='Wj7U9'><center id='Wj7U9'></center></pre></bdo></b><th id='Wj7U9'></th></span></q></dt></tr></i><div id='Wj7U9'><tfoot id='Wj7U9'></tfoot><dl id='Wj7U9'><fieldset id='Wj7U9'></fieldset></dl></div>

    <small id='Wj7U9'></small><noframes id='Wj7U9'>

    <tfoot id='Wj7U9'></tfoot>
    1. <legend id='Wj7U9'><style id='Wj7U9'><dir id='Wj7U9'><q id='Wj7U9'></q></dir></style></legend>

      • <bdo id='Wj7U9'></bdo><ul id='Wj7U9'></ul>

      Google OAuth令牌请求返回&quot;INVALID_CLIENT&QOT;:&QOO

      Google OAuth token request returns quot;invalid_clientquot;: quot;Unauthorizedquot;(Google OAuth令牌请求返回quot;INVALID_CLIENTQOT;:QOOT;未经授权QUOT;)

            <bdo id='ycs6S'></bdo><ul id='ycs6S'></ul>

            <legend id='ycs6S'><style id='ycs6S'><dir id='ycs6S'><q id='ycs6S'></q></dir></style></legend>
                <tbody id='ycs6S'></tbody>
              <tfoot id='ycs6S'></tfoot>

            1. <small id='ycs6S'></small><noframes id='ycs6S'>

              <i id='ycs6S'><tr id='ycs6S'><dt id='ycs6S'><q id='ycs6S'><span id='ycs6S'><b id='ycs6S'><form id='ycs6S'><ins id='ycs6S'></ins><ul id='ycs6S'></ul><sub id='ycs6S'></sub></form><legend id='ycs6S'></legend><bdo id='ycs6S'><pre id='ycs6S'><center id='ycs6S'></center></pre></bdo></b><th id='ycs6S'></th></span></q></dt></tr></i><div id='ycs6S'><tfoot id='ycs6S'></tfoot><dl id='ycs6S'><fieldset id='ycs6S'></fieldset></dl></div>

                本文介绍了Google OAuth令牌请求返回&quot;INVALID_CLIENT&QOT;:&QOOT;未经授权&QUOT;的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                正在尝试使OAuth2 Google登录正常工作,这是我的应用程序发出的原始请求:

                方法:POST

                URL:https://www.googleapis.com/oauth2/v3/token

                标题:Content-Type: application/x-www-form-urlencoded

                值:

                client_idXXX-0123456789abcdef0123456789abcdef.apps.googleusercontent.com

                client_secretA1b2C3d4E5f6G7h8I9j0K1l2M

                code1/A1b2C3d4E5f6G7h8I9j0K1l2M3n4O5p6Q7r8S9t0U1v

                grant_typeauthorization_code

                redirect_urihttp://localhost:5000/callback/google/

                这是响应:

                状态:401 Unauthorized

                正文:

                {
                    "error": "invalid_client",
                    "error_description": "Unauthorized"
                }
                

                我已验证这正是我的应用程序正在发出的请求/响应(使用Flask和Rauth的Python应用程序),并已验证我可以使用Postman重现完全相同的请求/响应。

                根据其他线程中的说明,我已经在Google API控制台中完成了以下所有操作:

                • 在"OAuth同意屏幕"设置中,将"产品名称"设置为与"项目名称"不同的名称
                • 同时在"OAuth同意屏幕"设置中,再次检查是否设置了电子邮件
                • 开启Google+API
                • 开启Gmail API
                • 重新创建客户端ID/密码
                • 仔细检查客户端ID/密码值是否没有前导空格或尾随空格,我已从API控制台正确复制

                无论我做什么,仍收到相同的"invalid_client": "Unauthorized"响应。

                在这方面提供帮助将不胜感激。我试着在我的应用程序中设置OAuth2驱动的"用X登录"功能,我已经让Facebook和Twitter正常工作了,我也想让谷歌工作,但如果我不能解决这个问题,我恐怕就不得不放弃谷歌身份验证了。

                推荐答案

                无效客户端表示您正在使用的客户端ID或客户端密钥无效。它们必须是您从Google开发人员控制台下载的。

                提示:您可能需要考虑使用Google python client库,它可以为您完成所有繁重任务。

                from __future__ import print_function
                import pickle
                import os.path
                from googleapiclient.discovery import build
                from google_auth_oauthlib.flow import InstalledAppFlow
                from google.auth.transport.requests import Request
                
                # If modifying these scopes, delete the file token.pickle.
                SCOPES = ['https://www.googleapis.com/auth/drive.metadata.readonly']
                
                def main():
                    """Shows basic usage of the Drive v3 API.
                    Prints the names and ids of the first 10 files the user has access to.
                    """
                    creds = None
                    # The file token.pickle stores the user's access and refresh tokens, and is
                    # created automatically when the authorization flow completes for the first
                    # time.
                    if os.path.exists('token.pickle'):
                        with open('token.pickle', 'rb') as token:
                            creds = pickle.load(token)
                    # If there are no (valid) credentials available, let the user log in.
                    if not creds or not creds.valid:
                        if creds and creds.expired and creds.refresh_token:
                            creds.refresh(Request())
                        else:
                            flow = InstalledAppFlow.from_client_secrets_file(
                                'credentials.json', SCOPES)
                            creds = flow.run_local_server(port=0)
                        # Save the credentials for the next run
                        with open('token.pickle', 'wb') as token:
                            pickle.dump(creds, token)
                
                    service = build('drive', 'v3', credentials=creds)
                
                    # Call the Drive v3 API
                    results = service.files().list(
                        pageSize=10, fields="nextPageToken, files(id, name)").execute()
                    items = results.get('files', [])
                
                    if not items:
                        print('No files found.')
                    else:
                        print('Files:')
                        for item in items:
                            print(u'{0} ({1})'.format(item['name'], item['id']))
                
                if __name__ == '__main__':
                    main()
                

                这篇关于Google OAuth令牌请求返回&quot;INVALID_CLIENT&QOT;:&QOOT;未经授权&QUOT;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                相关文档推荐

                groupby multiple coords along a single dimension in xarray(在xarray中按单个维度的多个坐标分组)
                Group by and Sum in Pandas without losing columns(Pandas中的GROUP BY AND SUM不丢失列)
                Group by + New Column + Grab value former row based on conditionals(GROUP BY+新列+基于条件的前一行抓取值)
                Groupby and interpolate in Pandas(PANDA中的Groupby算法和插值算法)
                Pandas - Group Rows based on a column and replace NaN with non-null values(PANAS-基于列对行进行分组,并将NaN替换为非空值)
                Grouping pandas DataFrame by 10 minute intervals(按10分钟间隔对 pandas 数据帧进行分组)

                <tfoot id='dtGHL'></tfoot>

                • <i id='dtGHL'><tr id='dtGHL'><dt id='dtGHL'><q id='dtGHL'><span id='dtGHL'><b id='dtGHL'><form id='dtGHL'><ins id='dtGHL'></ins><ul id='dtGHL'></ul><sub id='dtGHL'></sub></form><legend id='dtGHL'></legend><bdo id='dtGHL'><pre id='dtGHL'><center id='dtGHL'></center></pre></bdo></b><th id='dtGHL'></th></span></q></dt></tr></i><div id='dtGHL'><tfoot id='dtGHL'></tfoot><dl id='dtGHL'><fieldset id='dtGHL'></fieldset></dl></div>

                          <tbody id='dtGHL'></tbody>

                      • <legend id='dtGHL'><style id='dtGHL'><dir id='dtGHL'><q id='dtGHL'></q></dir></style></legend>
                          <bdo id='dtGHL'></bdo><ul id='dtGHL'></ul>

                          <small id='dtGHL'></small><noframes id='dtGHL'>