pythonandroidapigoogle-cloud-platformandroid-management-api

Error 400: invalid_request The out-of-band (OOB) flow has been blocked in order to keep users secure


using this quickstart.ipynb I'm getting this error You can’t sign in because "myapp" sent an invalid request. You can try again later, or contact the developer about this issue. Learn more about this error If you are a developer of myapp, see error details. Error 400: invalid_request

Error 400: invalid_request The out-of-band (OOB) flow has been blocked in order to keep users secure. Follow the Out-of-Band (OOB) flow Migration Guide linked in the developer docs below to migrate your app to an alternative method. Request details: redirect_uri=urn:ietf:wg:oauth:2.0:oob

This is the code which is running

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.')

Solution

  • Since Google has deprecated OOB

    You have to use the new method run_local_server() if you are using the google_auth_oauthlib package

    Replace the line

    credentials = flow.run_console()
    

    to

    credentials = flow.run_local_server()