Android Question Problem with Gmail REST API Tutorial

Status
Not open for further replies.

GaryK4

Member
Licensed User
Longtime User
I am trying to get the tutorial program working. When I run the program, google responds with error 400 Error: redirect_url_mismatch.
I do have a ClientId which I set in the program.
I also have a client secret and a downloaded client_secret.json file. I assume that one or both of these need to be referenced in the program. However, I could not find out how to do this. My searches did not come up with anything.
 

DonManfred

Expert
Licensed User
Longtime User
Upvote 0

GaryK4

Member
Licensed User
Longtime User
I read that along with many other threads. I downloaded and modified the tutorial https://www.b4x.com/android/forum/threads/b4x-sending-emails-with-gmail-rest-api.81736/#content
The tutorial fails. It does not mention that you need to define a redirect_url in the Google console.
Is the tutorial wrong? From what you are saying, it is incomplete.
I just tested the credentials with a visual studio .net program using the client_secret.json file, and that works.
I don't know how to add the Package SHA256 to the Google console.
 
Upvote 0

GaryK4

Member
Licensed User
Longtime User
Still getting error 400.
Modified the tutorial program
Tutorial says: "Set the package name or bundle identifier fields to your app's package name." I'm not sure what this means.
I set my package name to gk_test.googlecontacts I named the keystore file as gk_test.googlecontacts.keystore.
Created a new API Client ID for contacts and changed the programs ClientId.
I did not see anything about "add the Package SHA256 to the Google console" in the tutorial. Therefore it is not done?

Must be missing something simple.
 

Attachments

  • Screenshot_20190104-091358_Chrome[1].jpg
    Screenshot_20190104-091358_Chrome[1].jpg
    175.9 KB · Views: 177
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
I set my package name to gk_test.googlecontacts I named the keystore file as gk_test.googlecontacts.keystore.
The keystore file name is not important.


I did not see anything about "add the Package SHA256 to the Google console" in the tutorial. Therefore it is not done?
Not needed. Only the SHA1 signature is needed.

You need to set the package name and SHA1 signature here:

SS-2019-01-06_09.40.02.png
 
Upvote 0

GaryK4

Member
Licensed User
Longtime User
OK, that is what I needed. I don't know how I missed it.
Both test programs are now working.

Thanks for all the help.
 
Upvote 0

GaryK4

Member
Licensed User
Longtime User
Well, I was premature that all is OK. I actually have very mixed results.
The email tutorial works perfectly.
The contacts tutorial works, however it requests permissions every time.
When I add the email test into my main application, I get strange results.
When I run the program, it asks for permissions, however it says Choose an account to continue to B4A Gmail!
This is the gmail test program not the correct program.
The client ID's, keystore cert and package names are different.
If I allow access, it does not send the message or give an error.​
I do have (3) client ID's in the same project (see attachment.
B4A Gmail is the Tutorial program -- working.
PC contacts & Gmail - is for a dotnet test program that does email and contacts -- working.
Golf Match - is the main production -- Not working.
Note: the Golf Match program also has Google Maps in it. This as working great although warns that there is no application restrictions set.​
I have another project with only one client ID for the tutorial contacts program = semi-working.

Any ideas where I go from here?
 

Attachments

  • API Project.JPG
    API Project.JPG
    20.3 KB · Views: 177
Upvote 0
Status
Not open for further replies.
Top