private bool SaveParametersTokens(OAuthParameters parameters) { try { // first delete any old ones var oldTokens = (from t in context.GO_GoogleAuthorizeTokens select t); context.GO_GoogleAuthorizeTokens.DeleteAllOnSubmit(oldTokens); context.SubmitChanges(); // now create a new one GO_GoogleAuthorizeToken newToken = new GO_GoogleAuthorizeToken { Token = parameters.Token, TokenSecret = parameters.TokenSecret }; context.GO_GoogleAuthorizeTokens.InsertOnSubmit(newToken); context.SubmitChanges(); } catch { return(false); } return(true); }
private OAuthParameters BuildParameters() { // build the base parameters string scope = "https://www.google.com/calendar/feeds/ https://docs.google.com/feeds/ https://mail.google.com/mail/feed/atom/"; string callback = String.Format("http://{0}/Google/Oauth", Request.Url.Authority); OAuthParameters parameters = new OAuthParameters { ConsumerKey = kConsumerKey, ConsumerSecret = kConsumerSecret, Scope = scope, Callback = callback, SignatureMethod = "HMAC-SHA1" }; // check to see if we have saved tokens var tokens = (from a in context.GO_GoogleAuthorizeTokens select a); if (tokens.Count() > 0) { GO_GoogleAuthorizeToken token = tokens.First(); parameters.Token = token.Token; parameters.TokenSecret = token.TokenSecret; } return(parameters); }