What exactly does HealthVault's WebApplicationUtilities.GetPersonInfo( authToken ) need to function?

391 Views Asked by At

I am running in circles. I am using the HealthVault SDK (latest from NuGet) with our ASP.NET MVC application. My goal is to authorize our HealthVault application with a user, retrieve their PersonID and RecordID and store them in our database. I am unable to obtain a PersonInfo.

First, as according to http://msdn.microsoft.com/en-us/library/ff803620.aspx#AUTH I am redirecting the user to HealthVault to log in.

https://account.healthvault-ppe.com/redirect.aspx?target=AUTH&targetqs=?appid={AppId}%26redirect%3d{ReturnUrl}

I am successfully being redirected, I authorize my record and the app, and I am redirected back.

var target = Request.QueryString[ "target" ];
if (target == "APPAUTHSUCCESS") {
    var token = Request.QueryString[ "wctoken" ];
    var p = WebApplicationUtilities.GetPersonInfo( token );
}

The above code fails. Thrown on the line var p = WebApplicationUtilities.GetPersonInfo( token ).

Microsoft.Health.HealthServiceAccessDeniedException: Access is denied.

The token isn't null, the application has all permissions AND it returns success, and yet Access denied is always thrown. What could possibly be wrong?

1

There are 1 best solutions below

0
On

In my case this happened when my private key from PFX file (configured in web.config) did not match public key for the application.
I'm still using test environment and use https://config.healthvault-ppe.com to configure my applications.
Try extract public key (making .cer file) from your PFX file and upload it as a public key for the application.