This quick-start sample app is built in .NET and lets you get started with the Google+ platform in a few minutes. The app demonstrates:
- Using the Google+ Sign-In button to get an OAuth 2.0 refresh token.
- Exchanging the refresh token for an access token.
- Making Google+ API requests with the access token, including getting a list of people that the user has circled.
- Disconnecting the app from the user's Google account and revoking tokens.
- Supported operating systems:
- Visual Studio 2010 and later
Step 1: Enable the Google+ API
- Go to the Google API Console .
From the project drop-down, select an existing
or create a new one by selecting Create a new project.
Note: Use a single project to hold all platform instances of your app (Android, iOS, web, etc.), each with a different Client ID.
Enable the Google+ API service:
- In the list of Google APIs, search for the Google+ API service.
- Select Google+ API from the results list.
- Press the Enable API button. Wait for the API to be enabled.
In the sidebar under "APIs & Services", select Credentials, then select
the OAuth consent screen tab.
- Choose an Email Address, specify a Product Name, and press Save.
- In the Credentials tab, select the Create credentials drop-down list, and choose OAuth client ID.
Under Application type, select Web application.
Register the origins from which your app is allowed to access the Google APIs, as follows. An origin is a unique combination of protocol, hostname, and port.
for your app. You can enter multiple origins to allow for your app to run on different
protocols, domains, or subdomains. You cannot use wildcards. In the example below,
the second URL could be a production URL.
- Press the Create button.
- From the resulting OAuth client dialog box, copy the Client ID and Client secret. The Client ID lets your app access enabled Google APIs.
Step 2: Set up the .NET quick-start app
Get the latest version of the quick-start. One way is to use git to clone the application repository.
git clone https://github.com/googleplus/gplus-quickstart-csharp.git
Or, download the application as a zip file, and extract the library and quick-start code:
wget https://github.com/googleplus/gplus-quickstart-csharp/archive/master.zip -o gplus-quickstart-csharp.zip unzip gplus-quickstart-csharp.zip
gplus-quickstart-csharp/gplus-quickstart-csharp.slnwith Visual Studio.
YOUR_CLIENT_SECRETwith the values that you generated earlier in the API Console.
Step 3: Run the quick-start application
After you set up your Google API Console project and configure the quick-start app, the app is ready to run.
Because you registered
http://localhost:4567 as a Web origin in the
Google API Console, you will run the sample from that
- In Visual Studio, click Project > Enable NuGet Package Restore > answer Yes in the dialog.
- Right-click on the gplus-quickstart-csharp project and select Manage NuGet Packages.
- Click Restore on the Manage NuGet Packages window. This will install the Google API Client libraries.
- Close the NuGet Packages Window and try to build the project by pressing CTRL+SHIFT+B. The project should build successfully.
- Run the project by pressing the F5 key.
- Browse to your quick-start app, which by default is at:
Clicking Disconnect from Google+ results in the server making a call to Google to revoke the refresh token. The server then removes any data that it acquired from Google about the user to disconnect the app and follow the developer policies.