/// <summary>
        /// Store OAuth 2.0 credentials in the application's database.
        /// </summary>
        /// <param name="userId">User's ID.</param>
        /// <param name="credentials">The OAuth 2.0 credentials to store.</param>
        public static void StoreCredentials(String userId, IAuthorizationState credentials)
        {
            StoredCredential sc = db.StoredCredentials.FirstOrDefault(x => x.UserId == userId);

            if (sc != null)
            {
                sc.AccessToken  = credentials.AccessToken;
                sc.RefreshToken = credentials.RefreshToken;
            }
            else
            {
                db.StoredCredentials.InsertOnSubmit(new StoredCredential
                {
                    UserId       = userId,
                    AccessToken  = credentials.AccessToken,
                    RefreshToken = credentials.RefreshToken
                });
            }
            db.SubmitChanges();
        }
Esempio n. 2
0
 partial void DeleteStoredCredential(StoredCredential instance);
Esempio n. 3
0
 partial void UpdateStoredCredential(StoredCredential instance);
Esempio n. 4
0
 partial void InsertStoredCredential(StoredCredential instance);
Esempio n. 5
0
 /// <summary>
 /// Deprecated Method for adding a new object to the StoredCredentials EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToStoredCredentials(StoredCredential storedCredential)
 {
     base.AddObject("StoredCredentials", storedCredential);
 }
 partial void DeleteStoredCredential(StoredCredential instance);
 partial void UpdateStoredCredential(StoredCredential instance);
 partial void InsertStoredCredential(StoredCredential instance);