Partner-Center-DotNet-Samples icon indicating copy to clipboard operation
Partner-Center-DotNet-Samples copied to clipboard

Not able fetch refresh token

Open krunaldave24 opened this issue 4 years ago • 2 comments

Steps to reproduce

we have set all the information about the ad profile such as CSPAplication Id ,CSPApplicationSecret. when we try to login after set up values, it throw error for secret are not found at time of SetSecretAsync call. we try to run partner consent application to set refreshed token in key vault. we are using app only authentication in one of the tenants of our domains. Notfound

What steps can reproduce the defect?

  1. Asp.net core 3.1 C#
  2. region Assembly Microsoft.Azure.KeyVault, Version=3.0.4.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
  3. Method signature public static Task<SecretBundle> SetSecretAsync(this IKeyVaultClient operations, string vaultBaseUrl, string secretName, string value, IDictionary<string, string> tags = null, string contentType = null, SecretAttributes secretAttributes = null, CancellationToken cancellationToken = default);

Expected behavior

we get a refresh token for the defined user of azure portal for for given app managed key and corelated app registration client Id successfully.

Share the expected output

Actual behavior

please find the attached screen shot not found as above.

What is the behavior observed?

Diagnostic logs

at Microsoft.Azure.KeyVault.KeyVaultClient.<GetSecretWithHttpMessagesAsync>d__66.MoveNext() at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.ConfiguredTaskAwaitable1.ConfiguredTaskAwaiter.GetResult() at Microsoft.Azure.KeyVault.KeyVaultClientExtensions.<GetSecretAsync>d__12.MoveNext() at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.TaskAwaiter1.GetResult() at Application.Services.KeyVaultProvider.<GetSecretAsync>d__11.MoveNext() in D:\Projects\ClientApp\Src\Services\Application\Services\KeyVaultProvider.cs:line 51

Environment

azure cloud visual studio IDE

krunaldave24 avatar Oct 31 '20 12:10 krunaldave24

Im having the same problem.

Probably the procedure is not quite comprehensible for me. The code in CSPApplication demo seems to assume that the refresh token is already in the key vault? There also seems not to be any form of initial login procedure within the CSPApplication demo?

thepill avatar Apr 08 '21 07:04 thepill

@krunaldave24 i found my confusion and got it to work following https://github.com/microsoft/Partner-Center-DotNet-Samples/issues/45#issuecomment-737242542

You have to run the constent-web-sample first which will create the necessary secret within the key vault. After that the CSPApplication demo works if you fix this problem: https://github.com/microsoft/Partner-Center-DotNet-Samples/issues/55

thepill avatar Apr 08 '21 07:04 thepill