예제 #1
0
 public static void DropboxAuthEnd(this SessionState _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);
     }
 }
예제 #2
0
 public static SafeModeResult SaveOAuthToken(this SessionState _sessionState, OAuthTokenEx value)
 {
     return _sessionState.db.GetCollection<OAuthTokenEx>("OAuthTokenEx").Save(value, SafeMode.True);
 }
예제 #3
0
 public static void SaveNewToken(this SessionState _sessionState, OAuthTokenEx o)
 {
     o.PrivateData = AppCache.AESProvider.EncryptToString(JsonConvert.SerializeObject(new OAuthTokenExResource() { Secret = AppCache.token.Secret, Value = AppCache.token.Value }));
     _sessionState.SaveOAuthToken(o);
 }