private static void AddAccessTokenToHttpHeader <T>( HttpRequestMessage httpMessage, string profileId) where T : class { ISecureStore secureStore = (ISecureStore)Mvx.get_IoCProvider().Resolve <ISecureStore>(); IProfileDataService profileDataService = (IProfileDataService)Mvx.get_IoCProvider().Resolve <IProfileDataService>(); Profile profile = profileId != null?profileDataService.GetProfile(profileId) : profileDataService.GetActiveProfile(); if (profile == null) { return; } TokenData tokenData = secureStore.GetTokenData(profile.Id); if (tokenData == null) { return; } httpMessage.Headers.Add("Authorization", "bearer " + tokenData.AccessToken); }