Hello,
For my custom LucidChart extension, I am actively working on a .NET 8.X C# OAuth 2.0 client to the Lucid REST APIs. My approach was to create a LucidChartClientBase and then LucidChartUserClient and LucidChartAccountClient that derive from it.
Here is an example of what LucidChartUserClient looks like:
static async Task UserClientStuff()
{
var user_client = new LucidChartUserClient(clientId, clientSecret, redirectUri, userScopes);
await GetAccessTokenAsync(user_client);
try
{
var introspectionResult = await user_client.IntrospectTokenAsync(user_client.TokenDatae"access_token"].ToString());
Console.WriteLine($"Introspection result: {JsonConvert.SerializeObject(introspectionResult, Formatting.Indented)}");
var accountInfo = await user_client.GetAccountInfoAsync();
Console.WriteLine($"User profile: {accountInfo}");
// Fetch all documents without any filters
var allDocuments = await user_client.SearchDocumentsAsync();
// Process the list of documents as needed
foreach (var document in allDocuments.Where(x => x.Title == "DanFlowchart1"))
{
Console.WriteLine($"Document ID: {document.DocumentId}, Title: {document.Title}");
string documentId = document.DocumentId;
var documentContents = await user_client.GetDocumentContentsAsync(documentId);
Console.WriteLine($"Document Title: {documentContents.Title}");
foreach (var page in documentContents.Pages)
{
Console.WriteLine($"Page Title: {page.Title}");
foreach (var shape in page.Items.Shapes)
{
Console.WriteLine($"Shape ID: {shape.Id}, Class: {shape.Class}");
}
}
}
}
catch (Exception ex)
{
Console.WriteLine($"Error during token introspection: {ex.Message}");
}
}
Essentially, I have created a bunch of C# classes such as Document, DocumentContent, Shape, Items, etc. I would love to hear from other Lucid package creators to see if there would be interest in this code and collaborating. Let me know.
Thanks, Dan