Hello.
I use the Googleoauth2 class to send mail. Everything works fine, but when a week or so passes. the access token is not renewed and I get this error:
B4X:
Getting access token from refresh token...
ResponseError. Reason: , Response: {
"error": "invalid_grant",
"error_description": "Token has been expired or revoked."
}
Error accessing account.
Sub Class_Globals
Public oauth2 As GoogleOAuth2
Public ClientId As String = "*****"
End Sub
Private Sub B4XPage_Created (Root1 As B4XView)
Root = Root1
Root.LoadLayout("MainPage")
oauth2.Initialize(Me, "oauth2", ClientId, "https://www.googleapis.com/auth/gmail.send")
End Sub
Private Sub B4XPage_Foreground
oauth2.CallFromResume(B4XPages.GetNativeParent(Me).GetStartingIntent)
End Sub
Rectified, I also haven't managed to refresh the token in this simple example: https://www.b4x.com/android/forum/threads/b4x-sending-emails-with-gmail-rest-api.81736/#content
I think the error is in the google API console configuration. I create the project, enable the gmail API or service.
I create the credentials with the name, the package name of the APP and the SHA-1 fingerprint. in the consent screen, I have the project as external users and in tests. And with some test users added. Do I need to publish the APP for it to work? or it is not a problem for you to refresh the token. Thanks
I have services that run for many months and refresh the token automatically when needed. For example the service that manages the online libraries index.
I understand that this is how it should work, but I don't understand why my service only works for one week.
Believe that the configuration in the google api console is correct?