Forum Discussion

wjdavis's avatar
wjdavis
Copper Contributor
Dec 31, 2019

WVD API Authentication

I have a aspnetcore app that I'm writing and would like to be able to manage WVD resources. The problem I'm having is that the Bearer token I'm getting from Msal is giving me a 401 when I try to 

GET https://rdweb.wvd.microsoft.com/api/feeddiscovery/webfeeddiscovery.aspx

 

 

 

I thought maybe I needed to add an API permission to my app in azure, but I've already added:

https://management.azure.com/user_impersonation

 

 

 

 And I cant seem to locate anything that suggests it might work for WVD.

 

Maybe I'm way off track though. 

I've tried looking at the source:
https://github.com/Azure/RDS-Templates/tree/master/wvd-templates/wvd-management-ux/deploy 

 

But its been compiled and minified, so thats proving to be difficult.

 

Any help getting a valid token to call the WVD Rest API would be greatly appreciated.

 

Full Code:

 

var token = await TokenAcquisition.GetAccessTokenOnBehalfOfUserAsync(new[] { "<a href="https://mrs-Prod.ame.gbl/mrs-RDInfra-prod/user_impersonation" target="_blank">https://mrs-Prod.ame.gbl/mrs-RDInfra-prod/user_impersonation</a>" });
var httpClient = new HttpClient();
httpClient.BaseAddress = new Uri("<a href="https://rdweb.wvd.microsoft.com/" target="_blank">https://rdweb.wvd.microsoft.com/</a>");
httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", $"{token}");
var result = await httpClient.GetAsync("api/hubdiscovery/eventhubdiscovery.aspx");
result = await httpClient.GetAsync("api/feeddiscovery/webfeeddiscovery.aspx");
  • wjdavis's avatar
    wjdavis
    Copper Contributor
    Omg I just figured it out by comparing the token I got from the msft rdweb application:

    From the RDWeb App:
    "aud": "https://mrs-prod.ame.gbl/mrs-RDInfra-prod",

    From my App:
    "aud": "https://mrs-Prod.ame.gbl/mrs-RDInfra-prod",

    ....
    Yes I was using an uppercase P in - mrs-Prod. And the msft app was using a lowercase p in mrs-prod.

    I'm flabbergasted, angry and excited all at the same time.

    For the record I copied my value directly from Azure in my apps api permissions screen.

Resources