/// <summary> /// Advanced mode for library usage. Allows custom creation of HttpClient to account for future authentication methods /// </summary> /// <param name="customFactory">A function or lambda expression who is in charge of creating th HttpClient. It takes as an argument a HttpMessageHandler which does wiring for IFitbitInterceptor. To use IFitbitInterceptor you must pass this HttpMessageHandler as anargument to the constuctor of HttpClient</param> /// <param name="interceptor">An interface that enables sniffing all outgoing and incoming http requests from FitbitClient</param> public BandClient(Func <HttpMessageHandler, HttpClient> customFactory, IBandInterceptor interceptor = null, ITokenManager tokenManager = null) { this.OAuth2TokenAutoRefresh = false; ConfigureTokenManager(tokenManager); this.HttpClient = customFactory(new BandHttpMessageHandler(this, interceptor)); }
public BandHttpMessageHandler(BandClient fitbitClient, IBandInterceptor interceptor) { this.FitbitClient = fitbitClient; this.interceptor = interceptor; responseHandler = ResponseHandler; //Define the inner must handler. Otherwise exception is thrown. InnerHandler = new HttpClientHandler(); }
/// <summary> /// Simplest constructor for OAuth2- requires the minimum information required by FitBit.Net client to make succesful calls to Fitbit Api /// </summary> /// <param name="credentials">Obtain this information from your developer dashboard. App credentials are required to perform token refresh</param> /// <param name="accessToken">Authenticate with Fitbit API using OAuth2. Authenticator2 class is a helper for this process</param> /// <param name="interceptor">An interface that enables sniffing all outgoing and incoming http requests from FitbitClient</param> public BandClient(BandAppCredentials credentials, OAuth2AccessToken accessToken, IBandInterceptor interceptor = null, bool enableOAuth2TokenRefresh = true, ITokenManager tokenManager = null) { this.AppCredentials = credentials; this.AccessToken = accessToken; this.BandInterceptorPipeline = new List <IBandInterceptor>(); if (interceptor != null) { this.BandInterceptorPipeline.Add(interceptor); } ConfigureTokenManager(tokenManager); //Auto refresh should always be the last handle to be registered. ConfigureAutoRefresh(enableOAuth2TokenRefresh); CreateHttpClientForOAuth2(); }
public BandClient(BandAppCredentials credentials, OAuth2AccessToken accessToken, IBandInterceptor interceptor, ITokenManager tokenManager) : this(credentials, accessToken, interceptor, true, tokenManager) { }