Android Question Google oAuth2 - Access Blocked, the request is invalid

aaronk

Well-Known Member
Licensed User
Longtime User
Hi,

I am trying the Google oAuth2 for the first time.

I came across the following, and followed the steps from the link below:


I think I did something wrong somewhere, but can't work out where I have gone wrong.

I downloaded the example from the link above.
I am using it in B4A v12.80.
Running on a Pixel 8 with Android 14.

For testing, I am using the People API as per the example.

I kept everything the same and only changed the following:


Google Console

Created a new project. I called it 'PeopleAPITest'
I enabled the Google People API
Opened the 'Credentials' tab on the left of screen

It then says 'To create an OAuth client ID, you must first configure your consent screen'

I then selected User Type: External (as I can't select internal since it's only available for Google workplace)
App Name: PeopleAPITest
User support email: I selected my email from the list.
Developer email: I entered my email.

I clicked on Save & Continue on the Scopes.

Users, I added my developer email, and then clicked Save & Continue.

Clicked on 'Create credentials' and then selected 'OAuth client ID'
Application ID: Android
Name: Android client 1
Package name: b4a.peopleapitest
SHA-1 certificate fingerprint: In B4A I selected Tools - Private Sign Key and selected SHA1 from Certificate fingerprints 24:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:5A
It now shows a Client ID.

B4A
Changed the B4A app package name to b4a.peopleapitest
Changed the ClientId in the sample B4A app with the ClientID from Google Console as above.

When I run the project, and then tap on 'Get Data' it opens a chrome browser on my phone, and shows a message on the page saying Access Blocked, the request is invalid.

The email on the webpage on the phone shows my developer email, and is the same one I used above.

When I tap on 'error details' it shows:

Error 400: invalid_request
Custom URI scheme is not enabled for your Android client.

Anyone know where I have gone wrong ?

Screenshot.png
 

DonManfred

Expert
Licensed User
Longtime User
Custom URI scheme is not enabled for your Android client.
this is the error.

Have you added the manifestcode needed?

also you have to configure it in googleconsole
For the Android client you need to get the SHA-1 signature. It is available under Tools - Private Sign Key.
Set the package name or bundle identifier fields to your app's package name.
 
Upvote 0

aaronk

Well-Known Member
Licensed User
Longtime User
I worked out what was wrong.

In case anyone else comes along this, here is how I got it to work.

In the Google Console, open the 'Credentials' section on the left side.
Under the 'OAuth 2.0 Client IDs' section select the Android device. In my example it was 'Android client 1'.
Scroll down and select 'Advanced Settings'.
Even though it says This setting is not recommended for Android clients. Enable 'Enable custom URI scheme' anyway then click Save.
Now you need to wait five minutes to a few hours for settings to take effect. It took approximately 2-3 minutes for it to work for me.

Now I am not getting the issue I was originally getting.
 
Upvote 1
Top