Many nonprofit organizations use Google for Nonprofits including mail & calendar. In this post, we will show you how, step-by-step, to create Google Calendar Events from Blackbaud CRM™.
Before you get started, be sure you have the following prerequisites: Blackbaud CRM™ SDK, Visual Studio.
Part 1: Google Authentication
Your first step is to create an account through the Google Developer’s Console (https://console.developers.google.com/project). Creating a Google Developer's
account is straightforward as long as you have an existing Google account.
Next, you’ll need to create a new Project as shown below. The name can be anything you want, although it makes sense to be descriptive.
Under “APIs & auth/Credentials,” click “Create new Client ID” under “OAuth”
Select “Installed Application,” then proceed to the consent screen.
At minimum, you'll need to fill out the Product Name and Email Address
Next, you should be returned to the Create Client ID form. Under Installed Application Type, select “Other,” then click “Create Client ID.”
From here you should have a new Client ID. Click “Download JSON” and remember the location. We’ll need it as part of the Visual Studio project
The last step in the Developer’s Console is to allow a Google application to use authentication. Go to “APIs and auth/APIs,” then find “Calendar API” in the main list, and turn status to “ON”
Go to your Google Calendar and create an event.
Open Visual Studio. I am using 2013 in this example. Create a new Windows Forms Application in VB.NET
Next, you’ll need to import the appropriate Google APIs.
Tools>NuGet Package Manager>Manage NuGet Packages for Solution
Google APIs Auth Client Library
Then do the same thing, searching for “Google.Apis.Calendar.v3 Client Library”
Put the .json file you exported earlier in the bin/debug folder of the application.
On your form, place a button and a DataGridView Control, named btnGetEvents and grdEvents, respectively:
Add the following references to the form:
Add the following class-level variables:
Dim _scopes As IList(Of String) = New List(Of String)()
Dim _service As CalendarService
Dim _AllEvents As New List(Of Data.Event)
Add the following Subroutines. Note that much of this was initially grabbed from here: https://code.google.com/p/google-api-dotnet-client/source/browse/Calendar.VB.ConsoleApp/Program.vb?repo=samples
In the line “Dim jsonFile…” make sure your file name matches the one you downloaded earlier.
Also be sure your googleAccount matches your own.
Private Sub btnGetEvents_Click(sender As Object, e As EventArgs) Handles btnGetEvents.Click
Private Sub GetEvents()
Dim jsonFile As String = "client_secret_791792756839-c1ev8q9gjgvep2qm1v2cl872joh2pd98.apps.googleusercontent.com.json"
Dim credential As UserCredential
Dim secrets As ClientSecrets
Dim fds As New FileDataStore("Calendar.VB.Sample")
Dim googleAccount As String = "email@example.com"
Using stream As New FileStream(jsonFile, FileMode.Open, FileAccess.Read)
secrets = GoogleClientSecrets.Load(stream).Secrets
credential = GoogleWebAuthorizationBroker.AuthorizeAsync(secrets, _scopes, googleAccount, CancellationToken.None, fds).Result
' Create the calendar service using an initializer instance
Dim initializer As New BaseClientService.Initializer()
initializer.HttpClientInitializer = credential
initializer.ApplicationName = "VB.NET Calendar Sample"
_service = New CalendarService(initializer)
' Fetch the list of calendar list
Dim list As IList(Of CalendarListEntry) = _service.CalendarList.List().Execute().Items()
For Each calendar As Data.CalendarListEntry In list
' Display calendar's events
grdEvents.DataSource = _AllEvents
Catch ex As Exception
Private Sub AddEventsToList(list As CalendarListEntry)
Dim req As ListRequest = _service.Events.List(list.Id)
' Set MaxResults and TimeMin with sample values
req.MaxResults = 5
req.TimeMin = New DateTime(2013, 10, 1, 20, 0, 0)
' Fetch the list of events
Now run the application and click the Get Calendar Events button. You may first see a screen like this, prompting you to allow the application to manage your calendars.
If everything is successful, you should see your data grid populated like this:
Now you've connected Blackbaud CRM TMwith Google Calendar, Step 1: authenticating and returning calendars in .NET.
Next up we'll review Step 2 , create a calendar event and add it as a CRM data form extension. If you'd like more info, please contact us today.