Rookie C# authentication question

How do I authenticate a basic C# CLI application to send commits to a stream?

I’m trying to validate that I can send data to my locally running Speckle instance. From the web portal, I’ve managed to create an account and a stream to debug with.

In C#, with Speckle.Core, I’m trying to do this:

var streamUrl = "http://localhost:3000/streams/{streamId}";

var data = new Base();
data["test"] = "Some Value";

var commitId = Helpers.Send(streamUrl, data, "Test commit.").Result;

Unsurprisingly, I’m getting what appears to be an authentication error back:

You don't have any accounts for http://localhost:3000.

The docs I’m following have some references to SpeckleHelper, or an account parameter in a new Client(). Elsewhere in the docs there’s some detailed explanations of my options (apps and access tokens). But after crawling the forums and the Speckle.Core.Credentials.AccountManager, I can’t figure out where to place my auth information. I did find how to use the PAT if I were making bald REST calls, but I’d like to use the built-in helper if possible.

I’m not too picky about which auth method to use, but I do think I’ve missed some important information about how to authenticate at all. Any hints/guidance/references greatly appreciated. :pray:

1 Like

Hey @cdriesler.iv ,

Most of the docs assume you have Manager running locally where that C# code is executing, and so accounts would be picked directly from there.

If your environment does not have Manager installed, I’d suggest using an auth token instead.

And here is a simple example that shows how to “fake” an account and use it: Dev Q — barebones serverside example - #2 by teocomi

UPDATE:
If, instead, you want to perform the full OAuth dance from your app, you can use this method in Core, which spins up a local server and redirect the user to the web app to perform the login:

2 Likes

Everywhere I look I see Andrew

Many thanks @teocomi . I completely missed the Manager and will look into how to use it. But this got me unblocked and running. More questions to come I’m sure, but plenty to tinker with now.

1 Like