public IToken CreateTwoLeggedAccessToken(IOAuthContext context)
	{
		var accessToken = new AccessToken
                            {
                              ConsumerKey = context.ConsumerKey,
                              ExpireyDate = DateTime.UtcNow.AddDays(20),
                              Realm = context.Realm,
                              Token = Guid.NewGuid().ToString(),
                              TokenSecret = Guid.NewGuid().ToString(),
                              UserName = Guid.NewGuid().ToString(),
                            };
        _repository.SaveAccessToken(accessToken);

		return accessToken;
	}
Ejemplo n.º 2
0
    public ActionResult AuthorizeRequestToken(string oauth_token, string oauth_callback)
// ReSharper restore InconsistentNaming
    {
      var requestToken = _tokenRepository.GetRequestToken(oauth_token);
      if(requestToken!=null)
      {
        requestToken.AccessDenied = false;
        var accessToken = new AccessToken
                            {
                              ConsumerKey = requestToken.ConsumerKey,
                              ExpireyDate = DateTime.UtcNow.AddDays(20),
                              Realm = requestToken.Realm,
                              Token = Guid.NewGuid().ToString(),
                              TokenSecret = Guid.NewGuid().ToString(),
                              UserName = Guid.NewGuid().ToString(),
                            };
        requestToken.AccessToken = accessToken;
        _tokenRepository.SaveAccessToken(accessToken);
        _tokenRepository.SaveRequestToken(requestToken);
        return Json(new {Data=accessToken}, JsonRequestBehavior.AllowGet);
      }
      return new EmptyResult();
     
    }
Ejemplo n.º 3
0
 public void SaveAccessToken(AccessToken token)
 {
   _accessTokens[token.Token] = token;
 }