public void SetCalendar(string clientKey, string secretKey,int orgId) { string refreshToken = string.Empty; try { scopes.Add(CalendarService.Scope.Calendar); UserCredential credential = default(UserCredential); DatabaseDataStore _fdsToken; if (!string.IsNullOrEmpty(refreshToken)) { StoredResponse storedResponse = new StoredResponse(refreshToken); _fdsToken = new DatabaseDataStore(storedResponse, orgId); } else { _fdsToken = new DatabaseDataStore(orgId,clientKey,secretKey); } credential = GoogleWebAuthorizationBroker.AuthorizeAsync( new ClientSecrets { ClientId = clientKey, ClientSecret = secretKey, }, scopes, "Z", CancellationToken.None, _fdsToken).Result; credential.Token.ExpiresInSeconds = 500000; String token = credential.Token.RefreshToken; credential.Token.RefreshToken = refreshToken; //credential.Token.ExpiresInSeconds = 500000; // Create the calendar service using an initializer instance BaseClientService.Initializer initializer = new BaseClientService.Initializer(); initializer.HttpClientInitializer = credential; initializer.ApplicationName = "DPI Google Calendar"; service = new CalendarService(initializer); } catch (Exception ex) { //string text = File.ReadAllText("C://Google.txt"); //text = text + Environment.NewLine + ex.Message; //File.WriteAllText("C://Google.txt", text); } }
//Dev SetCalendar public void SetCalendar(int orgId, bool isSubscription = false) { string clientKey = string.Empty; string secretKey = string.Empty; string refreshToken = string.Empty; string name = "GoogleCalendar"; if (isSubscription) { name = "SubscribeGoogleCalendar"; } try { var dt = SelectClientCredentials(name, orgId); if (dt != null) { if (dt.Rows[0][0] != null) clientKey = dt.Rows[0][0].ToString(); if (dt.Rows[0][1] != null) secretKey = dt.Rows[0][1].ToString(); if (dt.Rows[0][2] != null) refreshToken = dt.Rows[0][2].ToString(); } scopes.Add(CalendarService.Scope.Calendar); UserCredential credential = default(UserCredential); DatabaseDataStore _fdsToken; if (!string.IsNullOrEmpty(refreshToken)) { StoredResponse storedResponse = new StoredResponse(refreshToken); _fdsToken = new DatabaseDataStore(storedResponse, orgId); } else { _fdsToken = new DatabaseDataStore(orgId); } credential = GoogleWebAuthorizationBroker.AuthorizeAsync( new ClientSecrets { ClientId = clientKey,// "532982290458-u189keaaki44sskvtki6p28rq5crjl6d.apps.googleusercontent.com", ClientSecret = secretKey,//"DDO62gcKn5nYWm4XCXlJkngo", }, scopes, "Z", CancellationToken.None, _fdsToken).Result; credential.Token.ExpiresInSeconds = 500000; String token = credential.Token.RefreshToken; credential.Token.RefreshToken = refreshToken; //credential.Token.ExpiresInSeconds = 500000; // Create the calendar service using an initializer instance BaseClientService.Initializer initializer = new BaseClientService.Initializer(); initializer.HttpClientInitializer = credential; initializer.ApplicationName = "DPI Google Calendar"; service = new CalendarService(initializer); } catch (Exception ex) { string text = File.ReadAllText("C://Google.txt"); text = text + Environment.NewLine + ex.Message; File.WriteAllText("C://Google.txt", text); } }
/// /// Clears all values in the data store. /// public Task ClearAsync() { this._storedResponse = new StoredResponse(); return(TaskEx.Delay(0)); }
/// /// Deletes StoredResponse. /// ///The key to delete from the data store public Task DeleteAsync(string key) { this._storedResponse = new StoredResponse(); return(TaskEx.Delay(0)); }
public SavedDataStore() { this._storedResponse = new StoredResponse(); }
/// /// Constructs Load previously saved StoredResponse. /// ///Stored response public SavedDataStore(StoredResponse pResponse) { this._storedResponse = pResponse; }