(Xojo Plugin) Google Sheets Refresh an Expired Access Token

I’d like some help refreshing an expired access token. Ultimately, I need this authorization to interact with google sheets.

I succeeded in generating a token using the Chilkat example:

(Xojo Plugin) Get a Google Sheets OAuth2 Access Token

It’s now expired before I had a chance to use it with the Chilkat example for creating a new spreadsheet.

And I’ve been unable to refresh it using the Chilkat example:

(Xojo Plugin) Google Sheets Refresh an Expired Access Token

The error I get is:

Failed to load googleSheets.json

Maybe I could solve this problem myself if I could understand why the following appears to be failing:

success = jsonToken.LoadFile(“qa_data/tokens/googleSheets.json”)

For starters, where is this path:


Is it somehow relative to the application that was used to generate the token in the first place?

Anyway, a little help would be greatly welcomed.

Hi @Matthew_Cottrell - I solved a similar issue for a member on this post. It seems like the same issue you may be having. If its a different path related issue then please post your debug message from the IDE?

This was my working example from that post link:

This is the code:

    Var jsonTestStr as String =  "{""Result"": ""OK"",""Reports"": [{""ReportTxt"": ["" "",""REPORT GROUP: DAILY REPORT""]}]}"
    Var json As New Chilkat.JsonObject
    Var success as Boolean = json.Load(jsonTestStr)
    json.EmitCompact = False

    Var fac As New Chilkat.FileAccess

    Var thisPathFolderItem as FolderItem = SpecialFolder.ApplicationData.Child("MyAzureFolder")
    If thisPathFolderItem.Exists = False Then
    End If

    thisPathFolderItem = SpecialFolder.ApplicationData.Child("MyAzureFolder").Child("microsoftGraph.json")
    Var filePathStr as String = thisPathFolderItem.NativePath
    success = fac.WriteEntireTextFile(filePathStr,json.Emit(),"utf-8",False)
1 Like

Mike’s suggested fix solved my problem completely.

A key realization was that the json file is supposed to be written to :

/Users/~/Library/Application Support/

Following Mike’s example and looking in the Applications Support folder made this work for me.

Thanks much

1 Like