//private readonly ITokenService tokenService; //public HomeController(ITokenService tokenService) //{ // this.tokenService = tokenService; //} public ActionResult Index() { // var token = tokenService.GenerateRandomToken(); // Substitute your Twilio AccountSid and ApiKey details var accountSid = "ACe60fd0aea5789edf56167aeed10e79ae"; var apiKey = "SK88d8d89c9d57c43fc8677f1053169513"; var apiSecret = "asMg80rqKGWjy4Bo1PPVA9K53tceJT5b"; Random rand = new Random(); var identity = rand.Next().ToString(); // Create a random identity for the client // Create a video grant for the token var grant = new VideoGrant(); var grants = new HashSet <IGrant> { grant }; // Create an Access Token generator var token = new Token(accountSid, apiKey, apiSecret, identity: identity, grants: grants); var tokenstring = token.ToJwt(); System.Diagnostics.Debug.WriteLine("asdasdasd"); var model = new TokenProfile { Token = tokenstring }; return(View("Index", model)); }
private static string PrepareExpectedResponse(AccountEntity accountEntity) { var accountTokens = accountEntity.Tokens.Select(x => new AccountToken(x.Issued, x.Expires, TokenProfile.ConvertToAccountTokenTypeEnum(x.Type.ConvertToEnumeration()), x.Value)); var getAccountResponse = new GetAccountResponse(accountEntity.Id, accountEntity.Email, accountEntity.Confirmed, accountEntity.Created, !string.IsNullOrWhiteSpace(accountEntity.PasswordHash), accountEntity.LastLogin, accountEntity.Roles.Select(x => x.RoleId), accountTokens); var settings = new JsonSerializerSettings { Formatting = Formatting.Indented, ContractResolver = new DefaultTestPlatformContractResolver { NamingStrategy = new CamelCaseNamingStrategy() }, Converters = new List <JsonConverter> { new StringEnumConverter() } }; return(JsonConvert.SerializeObject(getAccountResponse, settings)); }
protected Provider(TokenProfile profile) { _accessToken = profile.AccessToken; _refreshToken = profile.RefreshToken; _jsonMeta = profile.JsonMeta; }
protected Provider(TokenProfile profile, JsonMeta json) { // do stuff with JsonMeta object }
public SalesforceProvider(TokenProfile profile) : base(profile, new SalesforceJson()) { }
public async Task GetAccountAsync_Should_Return_OkObjectResult_With_GetAccountResponse() { var authResult = AuthorizationResult.Success(); var getAccountTokenOutputQueries = new List <GetAccountTokenOutputQuery> { new GetAccountTokenOutputQuery(DateTimeOffset.UtcNow, DateTimeOffset.UtcNow.AddDays(1), TokenTypeEnumeration.AccountConfirmation, "123456") }; var getAccountOutputQuery = new GetAccountOutputQuery(Guid.NewGuid(), "*****@*****.**", true, DateTimeOffset.UtcNow, true, null, new List <Guid> { Guid.NewGuid() }, getAccountTokenOutputQueries); var accountTokens = getAccountOutputQuery.Tokens.Select(x => new AccountToken(x.Issued, x.Expires, TokenProfile.ConvertToAccountTokenTypeEnum(x.Type), x.Value)); var getAccountResponse = new GetAccountResponse(getAccountOutputQuery.Id, getAccountOutputQuery.Email, getAccountOutputQuery.Confirmed, getAccountOutputQuery.Created, getAccountOutputQuery.PasswordAssigned, getAccountOutputQuery.LastLogin, getAccountOutputQuery.Roles, accountTokens); _authorizationServiceMock .Setup(x => x.AuthorizeAsync(It.IsAny <ClaimsPrincipal>(), It.IsAny <object>(), It.IsAny <string>())) .ReturnsAsync(authResult); _getAccountQueryHandlerMock .Setup(x => x.HandleAsync(It.IsAny <GetAccountInputQuery>(), It.IsAny <CancellationToken>())) .ReturnsAsync(getAccountOutputQuery); _mapperMock.Setup(x => x.Map <GetAccountOutputQuery, GetAccountResponse>(It.IsAny <GetAccountOutputQuery>())) .Returns(getAccountResponse); var result = await _controller.GetAccountAsync(getAccountOutputQuery.Id); var okResult = result.As <OkObjectResult>(); okResult.Value.Should().BeEquivalentTo(getAccountResponse); }