I’m working on a WPF app using .NET Core 6.0 and trying to integrate with the Miro platform API. I have my app credentials (client ID and secret) but I’m running into authorization issues when trying to create boards.
I can authenticate successfully, but when I try to make a POST request to create a new board, I get an Unauthorized error. I think there might be something wrong with how I’m handling the OAuth flow or passing the access token.
Here’s my current code:
public string AppId = "my_app_id";
public string AppSecret = "my_app_secret";
internal async void SetupMiroBoard()
{
try
{
var authClient = new RestClient("https://miro.com/app-install/?response_type=code&client_id=" + AppId);
var authRequest = new RestRequest();
authRequest.Method = Method.Post;
authRequest.AddHeader("Authorization", "Bearer " + AppSecret);
var authResponse = authClient.ExecuteAsync(authRequest);
var authResult = authResponse.Result;
var createClient = new RestClient("https://api.miro.com/v1/boards");
var createRequest = new RestRequest();
createRequest.Method = Method.Post;
createRequest.AddHeader("Accept", "application/json");
createRequest.AddHeader("Content-Type", "application/json");
createRequest.AddParameter("application/json", "{\"name\":\"My Board\",\"sharingPolicy\":{\"access\":\"private\",\"teamAccess\":\"private\"}}", ParameterType.RequestBody);
var createResponse = createClient.ExecuteAsync(createRequest);
var createResult = createResponse.Result; // Getting Unauthorized here
}
catch(Exception ex)
{
var errorMsg = ex.Message;
}
}
What am I missing in the authentication process? Do I need to handle the OAuth callback differently?