Seems I can't figure this out on my own. I'm trying to register a user for offline Healthvault access and I can't find a decent example that's less than four years old. HV has changed and so has MVC.
The way I understand it, you need basically four things to access a users information on Healthvault. The application certificate, the application ID associated with that certificate, the personId and the recordId. (It doesn't help that the last two get different names in different circumstances.)
I'm having problems handling the redirect after HV sends the user back. I can't seem to control where it's going or how to get the personId AND the recordId.
To help me understand what's going on what I want to do is build a very basic MVC application where a user clicks a button, they are taken to Healthvault where the authenticate themselves, authorize my application, they return to the application and I get their personId and recordId. I do NOT want to have them authenticate into my application using HV like most of the samples I've found do.
Any help in this regard is greatly appreciated.
Well, after days of work trying to understand the situation and finally writing up a question for here on StackOverflow I figured it out myself in just a couple of hours. Some days there are epiphanies and some days there are just Eh.
I hope to expand on this later but the short answer is that I put the Microsoft.Health.Web.MVC attribute [RequireSignIn] on the controller I was calling. That did as it was supposed to do and took me to Healthvault where I signed in. Now, to keep from being redirected back to the same controller and ending up in an endless loop, I had to go into the web config and change the app setting NonProductionActionUrlRedirectOverride to the controller and action I wanted to end up at.
The action in the controller looks like this:
The entry in the web config looks like this:
Once I'm back at the Healthvault controller Index action I'm going to have to pull the recordId, among other things, out of the URI so I can save those values for later access to the patients record.