public static void RedirectToLogin(Context context) { PreferenceHandler.setLoggedIn(false); PreferenceHandler.SetToken(string.Empty); PreferenceHandler.SetRefreshToken(string.Empty); Intent intent = new Intent(Application.Context, typeof(LoginNewActivity)); intent.PutExtra(LoginNewActivity.KEY_SHOW_PAGE, (int)SignInType.SIGN_IN); context.StartActivity(intent); }
public static async Task GetToken() { string tokenURL = string.Format(B2CConfig.TokenURL, B2CConfig.Tenant, B2CPolicy.SignInPolicyId, B2CConfig.ClientId, PreferenceHandler.GetAccessCode()); var response = await InvokeApi.Authenticate(tokenURL, string.Empty, HttpMethod.Post); if (response.StatusCode == System.Net.HttpStatusCode.OK) { string strContent = await response.Content.ReadAsStringAsync(); var tokenNew = JsonConvert.DeserializeObject <AccessToken>(strContent); PreferenceHandler.SetToken(tokenNew.id_token); PreferenceHandler.SetRefreshToken(tokenNew.refresh_token); } }