-
Notifications
You must be signed in to change notification settings - Fork 10
DotNet Guide
#Out Of Date This really has to be updated. If I've not done it yet, find me and yell at me. Sorry.
#Using gShell with C# and .Net gShell can be used with C# and .Net to allow you to simply make API calls, wrapping themselves in the secure gShell authentication files. It only takes a few steps.
- Build or install gShell as you normally would (installing is easier - someday I'll try to set this up with NuGet)
- Reference the gShell .dll file in your project (if you need the google APIs, I recommend using NuGet to add them as well)
- In your project, set up the scopes (permissions), create a new service, authenticate that service once for each domain you need to use it with and begin making your method calls:
HashSet<string> scopes = new HashSet<string>();
//this first scope is always required. aaaaalways.
scopes.Add(Google.Apis.Oauth2.v2.Oauth2Service.Scope.UserinfoEmail);
// you could also add "https://www.googleapis.com/auth/userinfo.email" if you don't want to add references to that package
scopes.Add(DirectoryService.Scope.AdminDirectoryUser);
OAuth2Base.SetScopes(scopes);
Directory directory = new Directory();
directory.Authenticate(Domain);
var User = directory.users.Get("MyUsername");
It's that easy! gShell only calls the Synchronous methods (the basic .Execute() methods), so if you want it to run with async you'll either need to make your own threading logic, or update the source code and make a pull request (hint, hint).
###Namespace Your available services are located in the gShell.dotNet namespace, and currently the following services are represented in full:
###Structure The methods are represented in the same class structure you'll find in the Google APIs, so just drill down until you find what you need!
###Example Project You can find an example project in the source code here: https://github.com/squid808/gShell/tree/master/gShell/gShell_dotNetTest
######Edited: 5/30/2015
News - Get Started - Cmdlet Index - FAQ - Discussion - Downloads