private static async Task MainAsync() { Mapper.Initialize(cfg => { cfg.AddProfile <IdentityServerProfile>(); }); IIdentityConfig config = new IdentityConfig(IdentityUri, GrandType, ClientId, ClientSecret, ApiName); IIdentityDiscoveryService discoveryService = new IdentityDiscoveryService(config); IIdentityTokenService tokenService = new IdentityTokenService(discoveryService, config); IIdentityIntrospectionService introspectionService = new IdentityIntrospectionService(discoveryService, config); IIdentityUserInfoService userInfoService = new IdentityUserInfoService(discoveryService); var phone = "79159771817"; await tokenService.GetCode(phone); Console.WriteLine("Code was sended, enter please"); var code = Console.ReadLine(); var token = await tokenService.GetToken(phone, code); var refreshedToken = await tokenService.RefreshToken(token.RefreshToken); var introspectionResponse = await introspectionService.IntrospectToken(refreshedToken.AccessToken); var userInfo = await userInfoService.GetUserInfo(refreshedToken.AccessToken); var t = ""; }
public async Task <bool> SignOut(string accessToken) { var result = false; var introspection = await IdentityIntrospectionService.IntrospectToken(accessToken); var discovery = await DiscoveryService.GetDiscovery(); var requestUrl = new RequestUrl(discovery.AuthorizeEndpoint); var url = requestUrl.CreateAuthorizeUrl(Config.ClientId, "id_token", "openid email TSAPI"); using (var client = new HttpClient()) { var response = await client.GetAsync(url); result = response.StatusCode == System.Net.HttpStatusCode.OK; } return(result); }