Skip to main content

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

Hello PromitaDa, thank you for posting.

 

This sounds like an incredible project and we are excited to see what you come up with. If you haven't already, perhaps you can create an open source repo to house it and post the link here? I would love to follow along there and see how it progresses.

 

If you can into any issues with something in the Lucid APIs not working as expected with the C# framework (or any others), please feel free to reach out here and we will be happy to help resolve it.


I just pushed the first commit to LucidApiClientDotnet repo hosted at github.

https://github.com/GreenShoesLLC/LucidApiClientDotnet

Please check it out.  If you are interesting in collaborating with me, let me know.

 


Thanks PromitaDan,

I look forward to watching the progression of this project.


Reply