android Error 400:invalid_request为了保证用户安全,带外(OOB)流已被阻止

11dmarpk  于 2022-12-21  发布在  Android
关注(0)|答案(2)|浏览(342)

我收到此错误您无法登录,因为“我的应用程序”发送了无效请求。您可以稍后重试,或者与开发人员联系以解决此问题。了解有关此错误的详细信息如果您是我的应用程序的开发人员,请参阅错误详细信息。无效请求
错误400:invalid_request带外(OOB)流已被阻止以保证用户安全。请按照下面的开发人员文档中链接的带外(OOB)流迁移指南将你的应用迁移到其他方法。请求详细信息:重定向URI = urn:ietf:工作组:开放式身份验证:2.0:oob
这是正在运行的代码

from apiclient.discovery import build
from google_auth_oauthlib.flow import InstalledAppFlow

CLIENT_CONFIG = {
'installed': {
'client_id':'----------------------------------------------------------',
'client_secret': '------------------------------------------------------',
'auth_uri':'https://accounts.google.com/o/oauth2/auth',
'token_uri':'https://oauth2.googleapis.com/token'
}
}
SCOPES = ['https://www.googleapis.com/auth/androidmanagement']

flow = InstalledAppFlow.from_client_config(CLIENT_CONFIG, SCOPES)
credentials = flow.run_console()

androidmanagement = build('androidmanagement', 'v1', credentials=credentials)

print('\nAuthentication succeeded.')
7cjasjjr

7cjasjjr1#

带外(OOB)流已被阻止。

使用下面的代码替换“您的客户ID”和“您的客户机密”

from apiclient.discovery import build
from google_auth_oauthlib.flow import Flow

# This is a public OAuth config that you can use to run this guide.
# However, use different credentials when building your own solution.
CLIENT_CONFIG = {
  'web': {
    'client_id':'your client id',
    'auth_uri':'https://accounts.google.com/o/oauth2/auth',
    'token_uri':'https://oauth2.googleapis.com/token',
'auth_provider_x509_cert_url':'https://www.googleapis.com/oauth2/v1/certs',
'client_secret':'your client secret'
  }
}
SCOPES = ['https://www.googleapis.com/auth/androidmanagement']
CALLBACK_URL = 'https://google.github.io/android-management-api-    samples/oauth_callback.html'

# Run the OAuth flow.
flow = Flow.from_client_config(CLIENT_CONFIG, SCOPES)
flow.redirect_uri = CALLBACK_URL
auth_url, _ = flow.authorization_url()
print('Please visit this URL to authorize this application:     {}'.format(auth_url))

code = input('Enter the authorization code: ')
flow.fetch_token(code=code)

# Create the API client.
androidmanagement = build('androidmanagement', 'v1',     credentials=flow.credentials)

print('\nAuthentication succeeded.')

Android管理API快速入门https://colab.research.google.com/github/google/android-management-api-samples/blob/master/notebooks/quickstart.ipynb的完整链接

bf1o4zei

bf1o4zei2#

由于Google已弃用OOB
如果您使用的是google_auth_oauthlib软件包,则必须使用新方法run_local_server()
更换管路

credentials = flow.run_console()

credentials = flow.run_local_server()

相关问题