OAuth and API

Yup, line is:

Dim fac As New Chilkat.FileAccess

success = fac.WriteEntireTextFile(prefFile.ShellPath,json.Emit(),"utf-8",False)

The output of the ShellPath is exactly /Users/mwilliams/Library/Application\ Support/com.customapp.oauth/ms\-tokens/microsoftGraph.json

FYI, I’ve also tried NativePath and other manual paths. Unfortunately the documentation regarding the root context of WriteEntireTextFile is opaque at best.

@Michael_Williams - On OS X I recreated what you are seeing. When I changed the folderpath to use NativePath for the String output it worked as expected (I failed when using FolderItem.ShellPath)

// MY TEST CODE TO PRODUCE A JSON RESULT
Var jsonTestStr as String =  "{""Result"": ""OK"",""Reports"": [{""ReportTxt"": ["" "",""REPORT GROUP: DAILY REPORT""]}]}"
Dim json As New Chilkat.JsonObject
Var success as Boolean = json.Load(jsonTestStr)
json.EmitCompact = False

Dim fac As New Chilkat.FileAccess

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

// SET FILENAME
thisPathFolderItem = SpecialFolder.ApplicationData.Child("MyAzureFolder").Child("microsoftGraph.json")


Var filePathStr as String = thisPathFolderItem.NativePath
success = fac.WriteEntireTextFile(filePathStr,json.Emit(),"utf-8",False)
System.DebugLog(fac.LastErrorText)

https://www.dropbox.com/s/mescuhhneadk0p9/testChilkatfile.xojo_binary_project?dl=1

Oh there are many ways to solve the problem. I was just giving a high level overview of how I managed to make it work without using the HTMLViewer.

1 Like

I appreciate that Thom as I struggled to figure out how to get the auth code back from the browser outside of using a plugin and the HTMLViewer. Thanks!

Eeeeesh! So, the combination of NOT relying on WriteEntireTextFile to create the file, along with use of NativePath worked. :triumph: Thanks for that!

1 Like