Hi guys !!!!
I'm trying to update a Google Spreadsheet, using OAuth2 library.
This is my piece of code:
The sentence oauth2.GetAccessToken prompts for the user to allow actions on the spreadsheet (edit, delete, ... ), after allowing those actions, it doesn't return to the app, instead of that the navigator is still showing. See images attached.
What other(s) action(s) do you consider are needed to send the data to the spreadsheet?
Thanks in advance, and best regards !!!
I'm trying to update a Google Spreadsheet, using OAuth2 library.
This is my piece of code:
B4X:
Sub Process_Globals
Dim ClientId As String = "..."
Private oauth2 As GoogleOAuth2
End Sub
Sub Activity_Create(FirstTime As Boolean)
...
If FirstTime Then
oauth2.Initialize(Me, "oauth2", ClientId, "https://www.googleapis.com/auth/spreadsheets")
End If
..
End Sub
Sub SendDataToGoogleSpreadsheet
Dim mylist As List
mylist.Initialize
Dim m As Map
m.Initialize
m.Put("Column1",MyColumn1Value)
m.Put("Column2",MyColumn1Value)
m.Put("Column3",MyColumn1Value)
m.Put("Column4",MyColumn1Value)
Dim j As JSONGenerator
j.Initialize2(mylist)
Dim job As HttpJob
job.Initialize("SendAssets", Me)
Dim text1 As JSONGenerator
text1.Initialize(m)
Dim SS As String
SS = text1.ToPrettyString(1)
oauth2.GetAccessToken
Wait For OAuth2_AccessTokenAvailable (Success As Boolean, Token As String)
If Success = False Then
ToastMessageShow("Error accessing account.", True)
Return
End If
job.PostString("https://sheets.googleapis.com/v4/spreadsheets/<spreadsheetID>/values/Sheet1!A1:D1:append?valueInputOption=USER_ENTERED", SS)
job.GetRequest.SetContentType("application/json")
Wait For (job) JobDone(job As HttpJob)
If job.Success = True Then
Log("Response Length:" & job.GetString.Length & " bytes")
Log(job.GetString)
End If
End Sub
The sentence oauth2.GetAccessToken prompts for the user to allow actions on the spreadsheet (edit, delete, ... ), after allowing those actions, it doesn't return to the app, instead of that the navigator is still showing. See images attached.
What other(s) action(s) do you consider are needed to send the data to the spreadsheet?
Thanks in advance, and best regards !!!