{"action":"created","comment":{"url":"https://api.github.com/repos/LindaLawton/Google-Dotnet-Samples/pulls/comments/46202729","id":46202729,"diff_hunk":"@@ -0,0 +1,239 @@\n+ \n+// Copyright 2015 DAIMTO :  www.daimto.com\n+//\n+// Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in compliance with\n+// the License. You may obtain a copy of the License at\n+//\n+// http://www.apache.org/licenses/LICENSE-2.0\n+//\n+// Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on\n+// an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the\n+// specific language governing permissions and limitations under the License.\n+//------------------------------------------------------------------------------\n+// <auto-generated>\n+//     This code was generated by DAIMTO-Google-apis-Sample-generator 1.0.0\n+//     Build date: 11/17/2015 13:52:58\n+//     C# generater version: 1.0.0\n+//\n+//     Changes to this file may cause incorrect behavior and will be lost if\n+//     the code is regenerated.\n+// </auto-generated>\n+//------------------------------------------------------------------------------\n+\n+using Google.Apis.Auth.OAuth2;\n+using Google.Apis.Analytics.v3;\n+using Google.Apis.Services;\n+using Google.Apis.Util.Store;\n+using System;\n+using System.IO;\n+using System.Security.Cryptography.X509Certificates;\n+using System.Threading;\n+\n+/// <summary>\n+/// API Name: Analytics.v3\n+/// Description: View and manage your Google Analytics data\n+/// Documentation: https://developers.google.com/analytics/\n+/// Nuget Package\n+/// https://www.nuget.org/packages/Google.Apis.Analytics.v3/\n+/// PM> Install-Package Google.Apis.Analytics.v3 \n+/// </summary>\n+namespace DAIMTO.Analytics.v3.Sample\n+{\n+    public class StandardGoogleAuth\n+    {\n+\n+\t /// <summary>\n+        /// The Google APIs Client Library for .net uses the client_secrets.json file format for storing the client_id, client_secret, and other OAuth 2.0 parameters.\n+        /// The client_secrets.json file format is a JSON formatted file containing the client ID, client secret, and other OAuth 2.0 parameters.\n+        ///      \n+        /// This file can be obtained from Google Developers console:   https://console.developers.google.com/project?authuser=0\n+        /// </summary>\n+        /// <param name=\"clientSecretJson\">Path to the client secret json file from Google Developers console.</param>\n+        /// <param name=\"userName\">The user to authorize.</param>\n+        /// <returns>a valid AnalyticsService</returns>\n+        public static AnalyticsService AuthenticateOauth(string clientSecretJson, string userName)\n+        {\n+            if (string.IsNullOrEmpty(userName))\n+                throw new Exception(\"userName is required for datastore.\");\n+\n+            if (!File.Exists(clientSecretJson))\n+                throw new Exception(\"Cant find Client Secret Json file.\");\n+\t\t\t\n+            string[] scopes = new string[] { AnalyticsService.Scope.Analytics,                       // View and manage your Google Analytics data\n+                                             AnalyticsService.Scope.AnalyticsEdit,                   // Edit Google Analytics management entities\n+                                             AnalyticsService.Scope.AnalyticsManageUsers,            // Manage Google Analytics Account users by email address\n+                                             AnalyticsService.Scope.AnalyticsManageUsersReadonly,    // View Google Analytics user permissions\n+                                             AnalyticsService.Scope.AnalyticsProvision,              // Create a new Google Analytics account along with its default property and view\n+                                             AnalyticsService.Scope.AnalyticsReadonly};              // View your Google Analytics data\n+            try\n+            {\n+                UserCredential credential;\n+                using (var stream = new FileStream(clientSecretJson, FileMode.Open, FileAccess.Read))\n+                {\n+                    string credPath = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal);\n+                    credPath = Path.Combine(credPath, \".credentials/Analytics\");\n+\n+                    credential = GoogleWebAuthorizationBroker.AuthorizeAsync(\n+                        GoogleClientSecrets.Load(stream).Secrets,\n+                        scopes,\n+                        userName,\n+                        CancellationToken.None,\n+                        new FileDataStore(credPath, true)).Result;\n+                    Console.WriteLine(\"Credential file saved to: \" + credPath);\n+                }\n+\n+                // Create Analytics API service.\n+                var service = new AnalyticsService(new BaseClientService.Initializer()\n+                    {\n+                        HttpClientInitializer = credential,\n+                        ApplicationName = \"Analytics Authentication Sample\",\n+                    });\n+                return service;","path":"Analyticsv3Sample/AnalyticsSampleProject/StandardGoogleAuthSample.cs","position":91,"original_position":91,"commit_id":"2215ac1b6401a945d20c904a9efb566293ce2124","original_commit_id":"2215ac1b6401a945d20c904a9efb566293ce2124","user":{"login":"LindaLawton","id":6592543,"avatar_url":"https://avatars.githubusercontent.com/u/6592543?v=3","gravatar_id":"","url":"https://api.github.com/users/LindaLawton","html_url":"https://github.com/LindaLawton","followers_url":"https://api.github.com/users/LindaLawton/followers","following_url":"https://api.github.com/users/LindaLawton/following{/other_user}","gists_url":"https://api.github.com/users/LindaLawton/gists{/gist_id}","starred_url":"https://api.github.com/users/LindaLawton/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/LindaLawton/subscriptions","organizations_url":"https://api.github.com/users/LindaLawton/orgs","repos_url":"https://api.github.com/users/LindaLawton/repos","events_url":"https://api.github.com/users/LindaLawton/events{/privacy}","received_events_url":"https://api.github.com/users/LindaLawton/received_events","type":"User","site_admin":false},"body":"Fixed and good point thanks","created_at":"2015-11-30T20:59:37Z","updated_at":"2015-11-30T20:59:37Z","html_url":"https://github.com/LindaLawton/Google-Dotnet-Samples/pull/10#discussion_r46202729","pull_request_url":"https://api.github.com/repos/LindaLawton/Google-Dotnet-Samples/pulls/10","_links":{"self":{"href":"https://api.github.com/repos/LindaLawton/Google-Dotnet-Samples/pulls/comments/46202729"},"html":{"href":"https://github.com/LindaLawton/Google-Dotnet-Samples/pull/10#discussion_r46202729"},"pull_request":{"href":"https://api.github.com/repos/LindaLawton/Google-Dotnet-Samples/pulls/10"}}},"pull_request":{"url":"https://api.github.com/repos/LindaLawton/Google-Dotnet-Samples/pulls/10","id":51835909,"html_url":"https://github.com/LindaLawton/Google-Dotnet-Samples/pull/10","diff_url":"https://github.com/LindaLawton/Google-Dotnet-Samples/pull/10.diff","patch_url":"https://github.com/LindaLawton/Google-Dotnet-Samples/pull/10.patch","issue_url":"https://api.github.com/repos/LindaLawton/Google-Dotnet-Samples/issues/10","number":10,"state":"open","locked":false,"title":"adding Analyticsv3Sample","user":{"login":"LindaLawton","id":6592543,"avatar_url":"https://avatars.githubusercontent.com/u/6592543?v=3","gravatar_id":"","url":"https://api.github.com/users/LindaLawton","html_url":"https://github.com/LindaLawton","followers_url":"https://api.github.com/users/LindaLawton/followers","following_url":"https://api.github.com/users/LindaLawton/following{/other_user}","gists_url":"https://api.github.com/users/LindaLawton/gists{/gist_id}","starred_url":"https://api.github.com/users/LindaLawton/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/LindaLawton/subscriptions","organizations_url":"https://api.github.com/users/LindaLawton/orgs","repos_url":"https://api.github.com/users/LindaLawton/repos","events_url":"https://api.github.com/users/LindaLawton/events{/privacy}","received_events_url":"https://api.github.com/users/LindaLawton/received_events","type":"User","site_admin":false},"body":"Code review welcome in the Analyticsv3Sample project","created_at":"2015-11-25T19:21:54Z","updated_at":"2015-11-30T20:59:37Z","closed_at":null,"merged_at":null,"merge_commit_sha":"fd4e47fbbba72149d6bc921edafffbd902c30995","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/LindaLawton/Google-Dotnet-Samples/pulls/10/commits","review_comments_url":"https://api.github.com/repos/LindaLawton/Google-Dotnet-Samples/pulls/10/comments","review_comment_url":"https://api.github.com/repos/LindaLawton/Google-Dotnet-Samples/pulls/comments{/number}","comments_url":"https://api.github.com/repos/LindaLawton/Google-Dotnet-Samples/issues/10/comments","statuses_url":"https://api.github.com/repos/LindaLawton/Google-Dotnet-Samples/statuses/2215ac1b6401a945d20c904a9efb566293ce2124","head":{"label":"LindaLawton:GeneratedSample","ref":"GeneratedSample","sha":"2215ac1b6401a945d20c904a9efb566293ce2124","user":{"login":"LindaLawton","id":6592543,"avatar_url":"https://avatars.githubusercontent.com/u/6592543?v=3","gravatar_id":"","url":"https://api.github.com/users/LindaLawton","html_url":"https://github.com/LindaLawton","followers_url":"https://api.github.com/users/LindaLawton/followers","following_url":"https://api.github.com/users/LindaLawton/following{/other_user}","gists_url":"https://api.github.com/users/LindaLawton/gists{/gist_id}","starred_url":"https://api.github.com/users/LindaLawton/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/LindaLawton/subscriptions","organizations_url":"https://api.github.com/users/LindaLawton/orgs","repos_url":"https://api.github.com/users/LindaLawton/repos","events_url":"https://api.github.com/users/LindaLawton/events{/privacy}","received_events_url":"https://api.github.com/users/LindaLawton/received_events","type":"User","site_admin":false},"repo":{"id":24324413,"name":"Google-Dotnet-Samples","full_name":"LindaLawton/Google-Dotnet-Samples","owner":{"login":"LindaLawton","id":6592543,"avatar_url":"https://avatars.githubusercontent.com/u/6592543?v=3","gravatar_id":"","url":"https://api.github.com/users/LindaLawton","html_url":"https://github.com/LindaLawton","followers_url":"https://api.github.com/users/LindaLawton/followers","following_url":"https://api.github.com/users/LindaLawton/following{/other_user}","gists_url":"https://api.github.com/users/LindaLawton/gists{/gist_id}","starred_url":"https://api.github.com/users/LindaLawton/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/LindaLawton/subscriptions","organizations_url":"https://api.github.com/users/LindaLawton/orgs","repos_url":"https://api.github.com/users/LindaLawton/repos","events_url":"https://api.github.com/users/LindaLawton/events{/privacy}","received_events_url":"https://api.github.com/users/LindaLawton/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/LindaLawton/Google-Dotnet-Samples","description":"Sample Projects for using the Google .net client lib - https://code.google.com/p/google-api-dotnet-client/","fork":false,"url":"https://api.github.com/repos/LindaLawton/Google-Dotnet-Samples","forks_url":"https://api.github.com/repos/LindaLawton/Google-Dotnet-Samples/forks","keys_url":"https://api.github.com/repos/LindaLawton/Google-Dotnet-Samples/keys{/key_id}","collaborators_url":"https://api.github.com/repos/LindaLawton/Google-Dotnet-Samples/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/LindaLawton/Google-Dotnet-Samples/teams","hooks_url":"https://api.github.com/repos/LindaLawton/Google-Dotnet-Samples/hooks","issue_events_url":"https://api.github.com/repos/LindaLawton/Google-Dotnet-Samples/issues/events{/number}","events_url":"https://api.github.com/repos/LindaLawton/Google-Dotnet-Samples/events","assignees_url":"https://api.github.com/repos/LindaLawton/Google-Dotnet-Samples/assignees{/user}","branches_url":"https://api.github.com/repos/LindaLawton/Google-Dotnet-Samples/branches{/branch}","tags_url":"https://api.github.com/repos/LindaLawton/Google-Dotnet-Samples/tags","blobs_url":"https://api.github.com/repos/LindaLawton/Google-Dotnet-Samples/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/LindaLawton/Google-Dotnet-Samples/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/LindaLawton/Google-Dotnet-Samples/git/refs{/sha}","trees_url":"https://api.github.com/repos/LindaLawton/Google-Dotnet-Samples/git/trees{/sha}","statuses_url":"https://api.github.com/repos/LindaLawton/Google-Dotnet-Samples/statuses/{sha}","languages_url":"https://api.github.com/repos/LindaLawton/Google-Dotnet-Samples/languages","stargazers_url":"https://api.github.com/repos/LindaLawton/Google-Dotnet-Samples/stargazers","contributors_url":"https://api.github.com/repos/LindaLawton/Google-Dotnet-Samples/contributors","subscribers_url":"https://api.github.com/repos/LindaLawton/Google-Dotnet-Samples/subscribers","subscription_url":"https://api.github.com/repos/LindaLawton/Google-Dotnet-Samples/subscription","commits_url":"https://api.github.com/repos/LindaLawton/Google-Dotnet-Samples/commits{/sha}","git_commits_url":"https://api.github.com/repos/LindaLawton/Google-Dotnet-Samples/git/commits{/sha}","comments_url":"https://api.github.com/repos/LindaLawton/Google-Dotnet-Samples/comments{/number}","issue_comment_url":"https://api.github.com/repos/LindaLawton/Google-Dotnet-Samples/issues/comments{/number}","contents_url":"https://api.github.com/repos/LindaLawton/Google-Dotnet-Samples/contents/{+path}","compare_url":"https://api.github.com/repos/LindaLawton/Google-Dotnet-Samples/compare/{base}...{head}","merges_url":"https://api.github.com/repos/LindaLawton/Google-Dotnet-Samples/merges","archive_url":"https://api.github.com/repos/LindaLawton/Google-Dotnet-Samples/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/LindaLawton/Google-Dotnet-Samples/downloads","issues_url":"https://api.github.com/repos/LindaLawton/Google-Dotnet-Samples/issues{/number}","pulls_url":"https://api.github.com/repos/LindaLawton/Google-Dotnet-Samples/pulls{/number}","milestones_url":"https://api.github.com/repos/LindaLawton/Google-Dotnet-Samples/milestones{/number}","notifications_url":"https://api.github.com/repos/LindaLawton/Google-Dotnet-Samples/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/LindaLawton/Google-Dotnet-Samples/labels{/name}","releases_url":"https://api.github.com/repos/LindaLawton/Google-Dotnet-Samples/releases{/id}","created_at":"2014-09-22T10:31:18Z","updated_at":"2015-11-23T09:44:19Z","pushed_at":"2015-11-25T19:21:54Z","git_url":"git://github.com/LindaLawton/Google-Dotnet-Samples.git","ssh_url":"git@github.com:LindaLawton/Google-Dotnet-Samples.git","clone_url":"https://github.com/LindaLawton/Google-Dotnet-Samples.git","svn_url":"https://github.com/LindaLawton/Google-Dotnet-Samples","homepage":"http://daimto.com/","size":20016,"stargazers_count":71,"watchers_count":71,"language":"C#","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":176,"mirror_url":null,"open_issues_count":5,"forks":176,"open_issues":5,"watchers":71,"default_branch":"master"}},"base":{"label":"LindaLawton:master","ref":"master","sha":"b2d1f5ecd37e3e971f046eaa9cbca948429dc04d","user":{"login":"LindaLawton","id":6592543,"avatar_url":"https://avatars.githubusercontent.com/u/6592543?v=3","gravatar_id":"","url":"https://api.github.com/users/LindaLawton","html_url":"https://github.com/LindaLawton","followers_url":"https://api.github.com/users/LindaLawton/followers","following_url":"https://api.github.com/users/LindaLawton/following{/other_user}","gists_url":"https://api.github.com/users/LindaLawton/gists{/gist_id}","starred_url":"https://api.github.com/users/LindaLawton/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/LindaLawton/subscriptions","organizations_url":"https://api.github.com/users/LindaLawton/orgs","repos_url":"https://api.github.com/users/LindaLawton/repos","events_url":"https://api.github.com/users/LindaLawton/events{/privacy}","received_events_url":"https://api.github.com/users/LindaLawton/received_events","type":"User","site_admin":false},"repo":{"id":24324413,"name":"Google-Dotnet-Samples","full_name":"LindaLawton/Google-Dotnet-Samples","owner":{"login":"LindaLawton","id":6592543,"avatar_url":"https://avatars.githubusercontent.com/u/6592543?v=3","gravatar_id":"","url":"https://api.github.com/users/LindaLawton","html_url":"https://github.com/LindaLawton","followers_url":"https://api.github.com/users/LindaLawton/followers","following_url":"https://api.github.com/users/LindaLawton/following{/other_user}","gists_url":"https://api.github.com/users/LindaLawton/gists{/gist_id}","starred_url":"https://api.github.com/users/LindaLawton/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/LindaLawton/subscriptions","organizations_url":"https://api.github.com/users/LindaLawton/orgs","repos_url":"https://api.github.com/users/LindaLawton/repos","events_url":"https://api.github.com/users/LindaLawton/events{/privacy}","received_events_url":"https://api.github.com/users/LindaLawton/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/LindaLawton/Google-Dotnet-Samples","description":"Sample Projects for using the Google .net client lib - https://code.google.com/p/google-api-dotnet-client/","fork":false,"url":"https://api.github.com/repos/LindaLawton/Google-Dotnet-Samples","forks_url":"https://api.github.com/repos/LindaLawton/Google-Dotnet-Samples/forks","keys_url":"https://api.github.com/repos/LindaLawton/Google-Dotnet-Samples/keys{/key_id}","collaborators_url":"https://api.github.com/repos/LindaLawton/Google-Dotnet-Samples/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/LindaLawton/Google-Dotnet-Samples/teams","hooks_url":"https://api.github.com/repos/LindaLawton/Google-Dotnet-Samples/hooks","issue_events_url":"https://api.github.com/repos/LindaLawton/Google-Dotnet-Samples/issues/events{/number}","events_url":"https://api.github.com/repos/LindaLawton/Google-Dotnet-Samples/events","assignees_url":"https://api.github.com/repos/LindaLawton/Google-Dotnet-Samples/assignees{/user}","branches_url":"https://api.github.com/repos/LindaLawton/Google-Dotnet-Samples/branches{/branch}","tags_url":"https://api.github.com/repos/LindaLawton/Google-Dotnet-Samples/tags","blobs_url":"https://api.github.com/repos/LindaLawton/Google-Dotnet-Samples/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/LindaLawton/Google-Dotnet-Samples/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/LindaLawton/Google-Dotnet-Samples/git/refs{/sha}","trees_url":"https://api.github.com/repos/LindaLawton/Google-Dotnet-Samples/git/trees{/sha}","statuses_url":"https://api.github.com/repos/LindaLawton/Google-Dotnet-Samples/statuses/{sha}","languages_url":"https://api.github.com/repos/LindaLawton/Google-Dotnet-Samples/languages","stargazers_url":"https://api.github.com/repos/LindaLawton/Google-Dotnet-Samples/stargazers","contributors_url":"https://api.github.com/repos/LindaLawton/Google-Dotnet-Samples/contributors","subscribers_url":"https://api.github.com/repos/LindaLawton/Google-Dotnet-Samples/subscribers","subscription_url":"https://api.github.com/repos/LindaLawton/Google-Dotnet-Samples/subscription","commits_url":"https://api.github.com/repos/LindaLawton/Google-Dotnet-Samples/commits{/sha}","git_commits_url":"https://api.github.com/repos/LindaLawton/Google-Dotnet-Samples/git/commits{/sha}","comments_url":"https://api.github.com/repos/LindaLawton/Google-Dotnet-Samples/comments{/number}","issue_comment_url":"https://api.github.com/repos/LindaLawton/Google-Dotnet-Samples/issues/comments{/number}","contents_url":"https://api.github.com/repos/LindaLawton/Google-Dotnet-Samples/contents/{+path}","compare_url":"https://api.github.com/repos/LindaLawton/Google-Dotnet-Samples/compare/{base}...{head}","merges_url":"https://api.github.com/repos/LindaLawton/Google-Dotnet-Samples/merges","archive_url":"https://api.github.com/repos/LindaLawton/Google-Dotnet-Samples/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/LindaLawton/Google-Dotnet-Samples/downloads","issues_url":"https://api.github.com/repos/LindaLawton/Google-Dotnet-Samples/issues{/number}","pulls_url":"https://api.github.com/repos/LindaLawton/Google-Dotnet-Samples/pulls{/number}","milestones_url":"https://api.github.com/repos/LindaLawton/Google-Dotnet-Samples/milestones{/number}","notifications_url":"https://api.github.com/repos/LindaLawton/Google-Dotnet-Samples/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/LindaLawton/Google-Dotnet-Samples/labels{/name}","releases_url":"https://api.github.com/repos/LindaLawton/Google-Dotnet-Samples/releases{/id}","created_at":"2014-09-22T10:31:18Z","updated_at":"2015-11-23T09:44:19Z","pushed_at":"2015-11-25T19:21:54Z","git_url":"git://github.com/LindaLawton/Google-Dotnet-Samples.git","ssh_url":"git@github.com:LindaLawton/Google-Dotnet-Samples.git","clone_url":"https://github.com/LindaLawton/Google-Dotnet-Samples.git","svn_url":"https://github.com/LindaLawton/Google-Dotnet-Samples","homepage":"http://daimto.com/","size":20016,"stargazers_count":71,"watchers_count":71,"language":"C#","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":176,"mirror_url":null,"open_issues_count":5,"forks":176,"open_issues":5,"watchers":71,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/LindaLawton/Google-Dotnet-Samples/pulls/10"},"html":{"href":"https://github.com/LindaLawton/Google-Dotnet-Samples/pull/10"},"issue":{"href":"https://api.github.com/repos/LindaLawton/Google-Dotnet-Samples/issues/10"},"comments":{"href":"https://api.github.com/repos/LindaLawton/Google-Dotnet-Samples/issues/10/comments"},"review_comments":{"href":"https://api.github.com/repos/LindaLawton/Google-Dotnet-Samples/pulls/10/comments"},"review_comment":{"href":"https://api.github.com/repos/LindaLawton/Google-Dotnet-Samples/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/LindaLawton/Google-Dotnet-Samples/pulls/10/commits"},"statuses":{"href":"https://api.github.com/repos/LindaLawton/Google-Dotnet-Samples/statuses/2215ac1b6401a945d20c904a9efb566293ce2124"}}}}