New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to authenticate FhirClient? #76

Closed
Aurimas86 opened this Issue Apr 30, 2015 · 1 comment

Comments

Projects
None yet
2 participants
@Aurimas86

Aurimas86 commented Apr 30, 2015

Let's say FHIR api got OAuth2 authentication on. Using OAuth2Client, I can receive authentication token. How could I use that token with FhirClient or is there another way to authenticate?

Btw, I can authenticate to HttpClient like this:

var client = new HttpClient();
client.SetBearerToken(response.AccessToken);

@ewoutkramer

This comment has been minimized.

Owner

ewoutkramer commented May 4, 2015

The FhirClient has two events and two overridable methods that you can use to hook into the request/response cycle:

public event BeforeRequestEventHandler OnBeforeRequest;
public event AfterResponseEventHandler OnAfterResponse;

 protected virtual void BeforeRequest(HttpWebRequest rawRequest) 
 protected virtual void AfterResponse(HttpWebResponse webResponse, ...)

As you can see, these give you access to the underlying .NET webrequest/response objects so you can set the required headers and parameters.

Let me know if you need more than these hooks!

@ewoutkramer ewoutkramer closed this May 4, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment