async Task SetIdentityValues(MobileServiceUser user) { //Manually calling /.auth/me against remote server because InvokeApiAsync against a local instance of Azure will never hit the remote endpoint //If you are not debugging your service locally, you can just use InvokeApiAsync("/.auth/me") if (_identity == null) { using (var client = new HttpClient()) { client.DefaultRequestHeaders.Add("ZUMO-API-VERSION", "2.0.0"); client.DefaultRequestHeaders.Add("X-ZUMO-AUTH", AzureService.Instance.Client.CurrentUser.MobileServiceAuthenticationToken); var json = await client.GetStringAsync($"{Keys.AzureDomainRemote}/.auth/me"); _identity = JsonConvert.DeserializeObject <List <AppServiceIdentity> >(json).FirstOrDefault(); } } if (_identity != null) { Settings.AzureAuthToken = user.MobileServiceAuthenticationToken; Settings.AzureUserId = user.UserId; switch (Keys.AuthenticationProvider) { case MobileServiceAuthenticationProvider.Google: Settings.RefreshToken = _identity.RefreshToken; Settings.AccessToken = _identity.AccessToken; break; case MobileServiceAuthenticationProvider.WindowsAzureActiveDirectory: break; } } }
async Task SetIdentityValues(MobileServiceUser user) { //Manually calling /.auth/me against remote server because InvokeApiAsync against a local instance of Azure will never hit the remote endpoint //If you are not debugging your service locally, you can just use InvokeApiAsync("/.auth/me") if(_identity == null) { using(var client = new HttpClient()) { client.DefaultRequestHeaders.Add("ZUMO-API-VERSION", "2.0.0"); client.DefaultRequestHeaders.Add("X-ZUMO-AUTH", AzureService.Instance.Client.CurrentUser.MobileServiceAuthenticationToken); var json = await client.GetStringAsync($"{Keys.AzureDomainRemote}/.auth/me"); _identity = JsonConvert.DeserializeObject<List<AppServiceIdentity>>(json).FirstOrDefault(); } } if(_identity != null) { Settings.AzureAuthToken = user.MobileServiceAuthenticationToken; Settings.AzureUserId = user.UserId; switch(Keys.AuthenticationProvider) { case MobileServiceAuthenticationProvider.Google: Settings.AccessToken = _identity.AccessToken; Settings.RefreshToken = _identity.RefreshToken; break; case MobileServiceAuthenticationProvider.WindowsAzureActiveDirectory: break; } } }