This quick-start app is built in C# / .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
To register a new application, do the following:
- Go to the Google Cloud Console.
- Select a project, or create a new one.
- In the sidebar on the left, select APIs & auth. In the displayed list of APIs, make sure the Google+ API status is set to ON.
- In the sidebar on the left, select Registered apps.
- At the top of the page, select Register App.
- Fill out the form and select Register.
Register the origins where your app is allowed to access the Google APIs. The origin is the unique combination of protocol, hostname, and port. You can enter multiple origins to allow for your app to run on different protocols, domains or subdomains. Wildcards are not allowed.
- Expand the OAuth 2.0 Client ID section.
In the Web origin field, enter your origin:
http://localhost:4567Press ENTER to save your origin. You can then click the + symbol to add additional origins.
- Note or copy the client ID and client secret that your app will need to use to access the APIs.
Step 2: Set up the C# / .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 sample code:
wget https://github.com/googleplus/gplus-quickstart-csharp/archive/master.zip unzip gplus-quickstart-csharp-master.zip
gplus-quickstart-csharp/gplus-quickstart-csharp.slnwith Visual Studio.
YOUR_CLIENT_SECRETwith the values that you generated earlier in the APIs Console.
Step 3: Run the application
After you set up your Google API project and configure the sample app, the app is ready to run.
Because you registered
origin in the Google APIs Console,
you will run the sample from that location.
- Press the F5 key in Visual Studio to build the project. The sample loads in your browser when the build finishes.
- 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.
Now that you have learned to create an APIs console project and run a sample app, you can learn more about the Google+ features you can add to your app: