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); } }
public static SafeModeResult SaveOAuthToken(this SessionState _sessionState, OAuthTokenEx value) { return _sessionState.db.GetCollection<OAuthTokenEx>("OAuthTokenEx").Save(value, SafeMode.True); }
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); }