Exemplo n.º 1
0
 public static void DropboxAuthEnd(this boSessionState _sessionState)
 {
     AuthorizedRequestToken authorizedRequestToken = new AuthorizedRequestToken(AppCache.requestToken, null);
     AppCache.token = AppCache.dropboxProvider.OAuthOperations.ExchangeForAccessTokenAsync(authorizedRequestToken, null).Result;
     OAuthTokenEx o = _sessionState.GetOAuthToken().FirstOrDefault();
     if (o == null)
     {
         o = new OAuthTokenEx();
         _sessionState.SaveNewToken(o);
     }
     else
     {
         dynamic pd = (new JsonSerializer()).Deserialize(new JsonTextReader(new StringReader(AppCache.AESProvider.DecryptString(o.PrivateData))));
         if (pd.Secret.Value != AppCache.token.Secret || pd.Value.Value != AppCache.token.Value)
             _sessionState.SaveNewToken(o);
     }
 }
Exemplo n.º 2
0
 public static SafeModeResult SaveOAuthToken(this boSessionState _sessionState, OAuthTokenEx value)
 {
     return _sessionState.db.GetCollection<OAuthTokenEx>("OAuthTokenEx").Save(value, SafeMode.True);
 }
Exemplo n.º 3
0
 public static void SaveNewToken(this boSessionState _sessionState, OAuthTokenEx o)
 {
     o.PrivateData = AppCache.AESProvider.EncryptToString(JsonConvert.SerializeObject(new OAuthTokenExResource() { Secret = AppCache.token.Secret, Value = AppCache.token.Value }));
     _sessionState.SaveOAuthToken(o);
 }