Hi,
Trying to access a Google Sheet using OAUTH v2.10
Getting this error...
My Code:
What am I doing wrong?
Trying to access a Google Sheet using OAUTH v2.10
Getting this error...
B4X:
ResponseError. Reason: , Response: {
"error": {
"code": 400,
"message": "API key not valid. Please pass a valid API key.",
"status": "INVALID_ARGUMENT",
"details": [
{
"@type": "type.googleapis.com/google.rpc.ErrorInfo",
"reason": "API_KEY_INVALID",
"domain": "googleapis.com",
"metadata": {
"service": "sheets.googleapis.com"
}
}
]
}
}
My Code:
B4X:
Dim sSTR As String = "https://sheets.googleapis.com/v4/spreadsheets/" & sheetID & "?ranges=" & range
oauth2.GetAccessToken
Wait For OAuth2_AccessTokenAvailable (Success As Boolean, Token As String)
If Success = False Then
ToastMessageShow("Error accessing account.", True)
Return
End If
Dim j As HttpJob
j.Initialize("", Me)
j.Download2(sSTR, Array As String("key", API_KEY))
j.GetRequest.SetHeader("Authorization", "Bearer " & Token)
If j.Success Then
Log(j.GetString)
Dim parser As JSONParser
parser.Initialize(j.GetString)
Dim root As Map = parser.NextObject
Dim values As List = root.Get("values")
Dim cindex, rindex As Int
Spn_Line.clear
For Each rowvalues As List In values 'get row
rindex=rindex+1
'Log("row: " & rowvalues)
For Each colvalues As String In rowvalues 'get column
cindex=cindex+1
Spn_Line.Add(colvalues)
Log(colvalues)
Log("rindex: " & rindex & "cindex: "&cindex)
Next
cindex = 0
Next
End If
j.Release
What am I doing wrong?