Share via

Why graph api does not work in VSTO?

Anonymous
2023-10-15T12:28:19+00:00

I am trying to work with graph API.

When I try to get the token, using the following code, on Winform application everything is working,

where running the same code from VSTO outlook adding, I get An error occurred while sending the request - An existing connection was forcibly closed by the remote host

what am I missing? or doing wrong?

the code is:

var app = PublicClientApplicationBuilder.Create(ThisAddIn.clientId).WithRedirectUri("http://localhost").Build();

string[] scopes = new string[] { "User.Read" };

var accounts = await app.GetAccountsAsync();

AuthenticationResult result = null;

try

{

          result = await app.AcquireTokenInteractive(scopes).ExecuteAsync();  // hear i get the error 

} catch (Exception ex)

{ MessageBox.Show($"Error: {ex.Message}"); }

Microsoft 365 and Office | Install, redeem, activate | For education | Other

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

1 answer

Sort by: Most helpful
  1. Anonymous
    2023-10-16T06:26:18+00:00

    Hi Bennym72,

    Graph API developing queries are not supported in this community. I would suggest you reach to Microsoft Graph - Microsoft Q&A for assistance. Experts there shall have more knowledge and experience on this topic.

    Best Regards,

    Ryan

    Was this answer helpful?

    0 comments No comments