Dim oAuth As GoogleOAuth2
Dim scope As String
Dim clientID As String
scope = "https://www.googleapis.com/auth/drive"
clientID = "xxx-xxxxxxxl.apps.googleusercontent.com"
oAuth.Initialize(Me,"oauth",clientID,scope)
wait for Init finisch...
B4X:
oAuth.GetAccessToken
the oAuth Page is Display, User allowed Access, no Access Token will display? Browser open the Google Page.
The CallFromResume will not be called (in Debug mode)??
Now with new versión 7.30 and Oauth, in v2 API, result are 100 records max !!!!
Wtih 7.30 and Oauth in v3 API the same, 100 records max, and minus fields
h.Download2("https://www.googleapis.com/drive/v3/files", _
Array As String("access_token", myToken, _
"corpora", "user", _
"q","mimeType!='application/vnd.google-apps.folder' and trashed=false"))
This is how the Api works.
It is similar in Dropbox Api.
If the result contains a "nextPageToken" then you need to use this token to get the next 100 results.
If the result contains a nextPageToken then you need to use this token to get the next 100 results.
and so on.
See Drive Api documentation for detailed informations.
What we do not understand is that in the previous version it worked in one way, and now it works in a totally different one, when the query is exactly the same. Why ???
Our problem is the sintax and make both at the same time with only one API. (v2 or v3)
Do you know this sintaxis DonManfred ??
Have you done any testing and it worked ???
With this syntax it is not necessary to exploit new tokens.
The result will contains all records, and will contains all fields.
But the syntax does not work !!!
Do you know how to write ???
Hola "mw71"
Another problem we have with the module, is that sometimes it identifies the user well with yours credentials, and the process works and end correctly. And other times it does not identify the user, leaving the process stopped and we do not know how to capture the error.
Where is the return to capture this error ??
Thack you in advance .
It looks like the token has to be renewed.
TestConnect should do this automatically.
B4X:
Sub TestConnect
Log("oAuth TestConnect")
ti.Valid=False
'request FileList
Dim h_tc As HttpJob
h_tc.Initialize("", Me)
h_tc.Download2("https://www.googleapis.com/drive/v3/files", _
Array As String("access_token", ti.AccessToken, _
"corpora", "user", _
"q","mimeType!='application/vnd.google-apps.folder' and trashed=false"))
Wait For (h_tc) JobDone(h_tc As HttpJob)
If h_tc.Success Then
'FileLliste receive, TestConecct success
Log(h_tc.GetString)
ti.Valid=True
Else
Log("OAuth, Getting access token from REFRESH token in TestConnect")
Dim j_rt As HttpJob
j_rt.Initialize("", Me)
j_rt.PostString("https://www.googleapis.com/oauth2/v4/token", _
$"refresh_token=${ti.RefreshToken}&client_id=${mClientId}&grant_type=refresh_token&redirect_uri=${packageName & ":/oath"}"$)
Wait For (j_rt) JobDone(j_rt As HttpJob)
If j_rt.Success Then
Log("OAuth TestConnect, Refresh access token Success")
Dim jp As JSONParser
jp.Initialize(j_rt.GetString)
Dim m As Map = jp.NextObject
ti.AccessExpiry = DateTime.Now + m.Get("expires_in")
ti.AccessToken = m.Get("access_token")
If m.ContainsKey("refresh_token") Then ti.RefreshToken = m.Get("refresh_token")
ti.Valid = True
SaveToken
Else
Log("OAuth TestConnect, Refresh Token ERROR")
End If
j_rt.Release
End If
h_tc.Release
CallSubDelayed3(mTarget, mEventName & "_TestFinish", ti.Valid, ti)
End Sub
True. We make modification and now, work perfctly.
Thank you very mutch !!!
B4X:
Sub X00_GdLst()
'Csr.LogMemory1(" X00_GdLst.Entra: (R." & RetryCon & ")", "1")
oauth2.GetAccessToken
Wait For OAuth2_AccessTokenAvailable (Success As Boolean, Token As String)
If Success = False Then
ToastMessageShow("Error accessing account.", True)
Return
Else
myToken=Token
oauth2.TestConnect
Wait For OAuth2_TestFinish(Erfolg As Boolean)
If EstaConectado Then
'X0_GdLst
X01_GetFileList("")
Else
If RetryCon <= 3 Then
RetryCon = RetryCon + 1
Csr.LogMemory1(" X00_GdLst.RetryCon: (R." & RetryCon & ")", "1")
X00_GdLst
Else
X55_GDLstSale(" X00_GdLst. Many.RetryCon(" & RetryCon & ")")
End If
End If
'''X55_GDLstSale(" X00_GdLst.NoConecction")
End If
End Sub