When I ask for the token following Erel's example (here) it works correctly and tells me that the token will last 60 minutes. When I refresh nothing changes, it gives me a response that doesn't change the duration and it doesn't give me a refresh token.
Following the instructions of several tutorials I set my application as public (no longer in testing phase) but nothing changed.
Other tutorials say that if it doesn't give you a Refresh Token, you should use the same Token for the refresh....
At the end of all experiments after 60 minutes I always have to authenticate again.
I recently had the same problem with my Dropbox-Library.
I had to rewrite the OAuthflow to use offline-mode to get a refreshtoken which i can use to generate a new AccessToken whenever i need to.
Yes, I have to re-authenticate with the browser. I know you can, unfortunately I can't. I would like to understand why it doesn't give me any refresh-token code
Public Sub GetAccessToken
If ti.Valid = False Then
Authenticate
Else If ti.AccessExpiry < DateTime.Now Then
GetTokenFromRefresh
Else
RaiseEvent(True)
End If
End Sub
ti.Valid should always be true. If it becomes false then the file was probably deleted, or you called ResetToken.
It becomes false without deleting the file and without resetting. After 60 minutes it no longer works. If I call refreshtoken 5 minutes before 60 minutes it returns "expired in 300" i.e. 5 minutes
I've tested them both, I've been studying them for 10 days. If I ask for a refresh before 60 minutes it gives me back the remaining time. If I call after 60 minutes it says the Token is not valid.
However, at the first login it should give me a refresh code in addition to the token, but it doesn't send it, some guides say that you have to use the same token as refresh, but it doesn't work
I still don't understand where it fails.
Change the sub to:
B4X:
Public Sub GetAccessToken
Log("valid? " & ti.Valid)
If ti.Valid = False Then
Authenticate
Else If ti.AccessExpiry < DateTime.Now Then
GetTokenFromRefresh
Else
RaiseEvent(True)
End If
End Sub
I recently had the same problem with my Dropbox-Library.
I had to rewrite the OAuthflow to use offline-mode to get a refreshtoken which i can use to generate a new AccessToken whenever i need to.
I recently had the same problem with my Dropbox-Library.
I had to rewrite the OAuthflow to use offline-mode to get a refreshtoken which i can use to generate a new AccessToken whenever i need to.
Private Sub Authenticate
#if B4J
PrepareServer
#End If
Dim link As String = BuildLink("https://accounts.google.com/o/oauth2/v2/auth", _
CreateMap("client_id": mClientId, _
"redirect_uri": GetRedirectUri, _
"response_type": "code", "scope": mScope, "access_type":"offline"))
#if B4A
Dim pi As PhoneIntents
StartActivity(pi.OpenBrowser(link))
#else if B4i
Main.App.OpenURL(link)
#else if B4J
fx.ShowExternalDocument(link)
#end if
End Sub