{"action":"created","comment":{"url":"https://api.github.com/repos/googleapis/toolkit/pulls/comments/76495187","id":76495187,"diff_hunk":"@@ -102,15 +102,59 @@\n   private final Table<Type, String, Field> fields = HashBasedTable.<Type, String, Field>create();\n \n   /*\n-   * The service canonical name, or name if no canonical name\n+   * The service canonical name, or name if no canonical name.\n    */\n   private String serviceCanonicalName;\n \n   /*\n-   * The service version string\n+   * The service version string.\n    */\n   private String serviceVersion;\n \n+  private Map<String, AuthType> authOverrides = new HashMap<>();\n+\n+  /*\n+   * If present in the scope list, indicates that the API supports application default credentials\n+   * based auth.\n+   */\n+  private static final String CLOUD_PLATFORM_SCOPE =\n+      \"https://www.googleapis.com/auth/cloud-platform\";\n+\n+  /*\n+   * Possible auth types supported by discovery.\n+   */\n+  public enum AuthType {\n+    APPLICATION_DEFAULT_CREDENTIALS,\n+    OAUTH_3L,\n+    API_KEY\n+  }\n+\n+  /*\n+   * Returns the auth type supported by the service.\n+   */\n+  public AuthType getAuthType() {\n+    String key = getServiceCanonicalName();\n+    if (authOverrides.containsKey(key)) {\n+      return authOverrides.get(key);\n+    }\n+    // This statement is based on the assumption that every method in a service contains all the\n+    // scopes necessary to determine the correct auth mechanism for the entire service.\n+    // Therefore, we use the scopes of the first method in the auth scopes array.\n+    key = getAuthScopes().keySet().iterator().next();\n+    List<String> scopes = getAuthScopes().get(key);\n+    if (scopes.isEmpty()) {\n+      // If there are no scopes, it's api key based.","path":"src/main/java/com/google/api/codegen/ApiaryConfig.java","position":47,"original_position":47,"commit_id":"a0ea4d026ee0d24e691370f573deb3d4f8558cee","original_commit_id":"a0ea4d026ee0d24e691370f573deb3d4f8558cee","user":{"login":"vchudnov-g","id":5422149,"avatar_url":"https://avatars.githubusercontent.com/u/5422149?v=3","gravatar_id":"","url":"https://api.github.com/users/vchudnov-g","html_url":"https://github.com/vchudnov-g","followers_url":"https://api.github.com/users/vchudnov-g/followers","following_url":"https://api.github.com/users/vchudnov-g/following{/other_user}","gists_url":"https://api.github.com/users/vchudnov-g/gists{/gist_id}","starred_url":"https://api.github.com/users/vchudnov-g/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vchudnov-g/subscriptions","organizations_url":"https://api.github.com/users/vchudnov-g/orgs","repos_url":"https://api.github.com/users/vchudnov-g/repos","events_url":"https://api.github.com/users/vchudnov-g/events{/privacy}","received_events_url":"https://api.github.com/users/vchudnov-g/received_events","type":"User","site_admin":false},"body":"\"API Key-based\"","created_at":"2016-08-26T22:05:55Z","updated_at":"2016-08-26T22:05:55Z","html_url":"https://github.com/googleapis/toolkit/pull/429#discussion_r76495187","pull_request_url":"https://api.github.com/repos/googleapis/toolkit/pulls/429","_links":{"self":{"href":"https://api.github.com/repos/googleapis/toolkit/pulls/comments/76495187"},"html":{"href":"https://github.com/googleapis/toolkit/pull/429#discussion_r76495187"},"pull_request":{"href":"https://api.github.com/repos/googleapis/toolkit/pulls/429"}}},"pull_request":{"url":"https://api.github.com/repos/googleapis/toolkit/pulls/429","id":82952138,"html_url":"https://github.com/googleapis/toolkit/pull/429","diff_url":"https://github.com/googleapis/toolkit/pull/429.diff","patch_url":"https://github.com/googleapis/toolkit/pull/429.patch","issue_url":"https://api.github.com/repos/googleapis/toolkit/issues/429","number":429,"state":"open","locked":false,"title":"Add API key and 3LO scaffold to discovery","user":{"login":"saicheems","id":2468087,"avatar_url":"https://avatars.githubusercontent.com/u/2468087?v=3","gravatar_id":"","url":"https://api.github.com/users/saicheems","html_url":"https://github.com/saicheems","followers_url":"https://api.github.com/users/saicheems/followers","following_url":"https://api.github.com/users/saicheems/following{/other_user}","gists_url":"https://api.github.com/users/saicheems/gists{/gist_id}","starred_url":"https://api.github.com/users/saicheems/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/saicheems/subscriptions","organizations_url":"https://api.github.com/users/saicheems/orgs","repos_url":"https://api.github.com/users/saicheems/repos","events_url":"https://api.github.com/users/saicheems/events{/privacy}","received_events_url":"https://api.github.com/users/saicheems/received_events","type":"User","site_admin":false},"body":"Adds 3 methods to ApiaryConfig that allow language contexts to print the\r\ncorrect auth boilerplate.","created_at":"2016-08-26T20:49:57Z","updated_at":"2016-08-26T22:05:55Z","closed_at":null,"merged_at":null,"merge_commit_sha":"809dd506d140fc708e916f934451a3e2c3a815c3","assignee":{"login":"pongad","id":1617025,"avatar_url":"https://avatars.githubusercontent.com/u/1617025?v=3","gravatar_id":"","url":"https://api.github.com/users/pongad","html_url":"https://github.com/pongad","followers_url":"https://api.github.com/users/pongad/followers","following_url":"https://api.github.com/users/pongad/following{/other_user}","gists_url":"https://api.github.com/users/pongad/gists{/gist_id}","starred_url":"https://api.github.com/users/pongad/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pongad/subscriptions","organizations_url":"https://api.github.com/users/pongad/orgs","repos_url":"https://api.github.com/users/pongad/repos","events_url":"https://api.github.com/users/pongad/events{/privacy}","received_events_url":"https://api.github.com/users/pongad/received_events","type":"User","site_admin":false},"assignees":[{"login":"pongad","id":1617025,"avatar_url":"https://avatars.githubusercontent.com/u/1617025?v=3","gravatar_id":"","url":"https://api.github.com/users/pongad","html_url":"https://github.com/pongad","followers_url":"https://api.github.com/users/pongad/followers","following_url":"https://api.github.com/users/pongad/following{/other_user}","gists_url":"https://api.github.com/users/pongad/gists{/gist_id}","starred_url":"https://api.github.com/users/pongad/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pongad/subscriptions","organizations_url":"https://api.github.com/users/pongad/orgs","repos_url":"https://api.github.com/users/pongad/repos","events_url":"https://api.github.com/users/pongad/events{/privacy}","received_events_url":"https://api.github.com/users/pongad/received_events","type":"User","site_admin":false},{"login":"vchudnov-g","id":5422149,"avatar_url":"https://avatars.githubusercontent.com/u/5422149?v=3","gravatar_id":"","url":"https://api.github.com/users/vchudnov-g","html_url":"https://github.com/vchudnov-g","followers_url":"https://api.github.com/users/vchudnov-g/followers","following_url":"https://api.github.com/users/vchudnov-g/following{/other_user}","gists_url":"https://api.github.com/users/vchudnov-g/gists{/gist_id}","starred_url":"https://api.github.com/users/vchudnov-g/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vchudnov-g/subscriptions","organizations_url":"https://api.github.com/users/vchudnov-g/orgs","repos_url":"https://api.github.com/users/vchudnov-g/repos","events_url":"https://api.github.com/users/vchudnov-g/events{/privacy}","received_events_url":"https://api.github.com/users/vchudnov-g/received_events","type":"User","site_admin":false}],"milestone":null,"commits_url":"https://api.github.com/repos/googleapis/toolkit/pulls/429/commits","review_comments_url":"https://api.github.com/repos/googleapis/toolkit/pulls/429/comments","review_comment_url":"https://api.github.com/repos/googleapis/toolkit/pulls/comments{/number}","comments_url":"https://api.github.com/repos/googleapis/toolkit/issues/429/comments","statuses_url":"https://api.github.com/repos/googleapis/toolkit/statuses/a0ea4d026ee0d24e691370f573deb3d4f8558cee","head":{"label":"saicheems:newauth","ref":"newauth","sha":"a0ea4d026ee0d24e691370f573deb3d4f8558cee","user":{"login":"saicheems","id":2468087,"avatar_url":"https://avatars.githubusercontent.com/u/2468087?v=3","gravatar_id":"","url":"https://api.github.com/users/saicheems","html_url":"https://github.com/saicheems","followers_url":"https://api.github.com/users/saicheems/followers","following_url":"https://api.github.com/users/saicheems/following{/other_user}","gists_url":"https://api.github.com/users/saicheems/gists{/gist_id}","starred_url":"https://api.github.com/users/saicheems/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/saicheems/subscriptions","organizations_url":"https://api.github.com/users/saicheems/orgs","repos_url":"https://api.github.com/users/saicheems/repos","events_url":"https://api.github.com/users/saicheems/events{/privacy}","received_events_url":"https://api.github.com/users/saicheems/received_events","type":"User","site_admin":false},"repo":{"id":57332880,"name":"toolkit","full_name":"saicheems/toolkit","owner":{"login":"saicheems","id":2468087,"avatar_url":"https://avatars.githubusercontent.com/u/2468087?v=3","gravatar_id":"","url":"https://api.github.com/users/saicheems","html_url":"https://github.com/saicheems","followers_url":"https://api.github.com/users/saicheems/followers","following_url":"https://api.github.com/users/saicheems/following{/other_user}","gists_url":"https://api.github.com/users/saicheems/gists{/gist_id}","starred_url":"https://api.github.com/users/saicheems/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/saicheems/subscriptions","organizations_url":"https://api.github.com/users/saicheems/orgs","repos_url":"https://api.github.com/users/saicheems/repos","events_url":"https://api.github.com/users/saicheems/events{/privacy}","received_events_url":"https://api.github.com/users/saicheems/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/saicheems/toolkit","description":"","fork":true,"url":"https://api.github.com/repos/saicheems/toolkit","forks_url":"https://api.github.com/repos/saicheems/toolkit/forks","keys_url":"https://api.github.com/repos/saicheems/toolkit/keys{/key_id}","collaborators_url":"https://api.github.com/repos/saicheems/toolkit/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/saicheems/toolkit/teams","hooks_url":"https://api.github.com/repos/saicheems/toolkit/hooks","issue_events_url":"https://api.github.com/repos/saicheems/toolkit/issues/events{/number}","events_url":"https://api.github.com/repos/saicheems/toolkit/events","assignees_url":"https://api.github.com/repos/saicheems/toolkit/assignees{/user}","branches_url":"https://api.github.com/repos/saicheems/toolkit/branches{/branch}","tags_url":"https://api.github.com/repos/saicheems/toolkit/tags","blobs_url":"https://api.github.com/repos/saicheems/toolkit/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/saicheems/toolkit/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/saicheems/toolkit/git/refs{/sha}","trees_url":"https://api.github.com/repos/saicheems/toolkit/git/trees{/sha}","statuses_url":"https://api.github.com/repos/saicheems/toolkit/statuses/{sha}","languages_url":"https://api.github.com/repos/saicheems/toolkit/languages","stargazers_url":"https://api.github.com/repos/saicheems/toolkit/stargazers","contributors_url":"https://api.github.com/repos/saicheems/toolkit/contributors","subscribers_url":"https://api.github.com/repos/saicheems/toolkit/subscribers","subscription_url":"https://api.github.com/repos/saicheems/toolkit/subscription","commits_url":"https://api.github.com/repos/saicheems/toolkit/commits{/sha}","git_commits_url":"https://api.github.com/repos/saicheems/toolkit/git/commits{/sha}","comments_url":"https://api.github.com/repos/saicheems/toolkit/comments{/number}","issue_comment_url":"https://api.github.com/repos/saicheems/toolkit/issues/comments{/number}","contents_url":"https://api.github.com/repos/saicheems/toolkit/contents/{+path}","compare_url":"https://api.github.com/repos/saicheems/toolkit/compare/{base}...{head}","merges_url":"https://api.github.com/repos/saicheems/toolkit/merges","archive_url":"https://api.github.com/repos/saicheems/toolkit/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/saicheems/toolkit/downloads","issues_url":"https://api.github.com/repos/saicheems/toolkit/issues{/number}","pulls_url":"https://api.github.com/repos/saicheems/toolkit/pulls{/number}","milestones_url":"https://api.github.com/repos/saicheems/toolkit/milestones{/number}","notifications_url":"https://api.github.com/repos/saicheems/toolkit/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/saicheems/toolkit/labels{/name}","releases_url":"https://api.github.com/repos/saicheems/toolkit/releases{/id}","deployments_url":"https://api.github.com/repos/saicheems/toolkit/deployments","created_at":"2016-04-28T20:49:44Z","updated_at":"2016-04-28T20:49:47Z","pushed_at":"2016-08-26T22:00:08Z","git_url":"git://github.com/saicheems/toolkit.git","ssh_url":"git@github.com:saicheems/toolkit.git","clone_url":"https://github.com/saicheems/toolkit.git","svn_url":"https://github.com/saicheems/toolkit","homepage":null,"size":6755,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"googleapis:master","ref":"master","sha":"a705d4e3d94295ab42ba117cec406f18cb9d3965","user":{"login":"googleapis","id":16785467,"avatar_url":"https://avatars.githubusercontent.com/u/16785467?v=3","gravatar_id":"","url":"https://api.github.com/users/googleapis","html_url":"https://github.com/googleapis","followers_url":"https://api.github.com/users/googleapis/followers","following_url":"https://api.github.com/users/googleapis/following{/other_user}","gists_url":"https://api.github.com/users/googleapis/gists{/gist_id}","starred_url":"https://api.github.com/users/googleapis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/googleapis/subscriptions","organizations_url":"https://api.github.com/users/googleapis/orgs","repos_url":"https://api.github.com/users/googleapis/repos","events_url":"https://api.github.com/users/googleapis/events{/privacy}","received_events_url":"https://api.github.com/users/googleapis/received_events","type":"Organization","site_admin":false},"repo":{"id":56533838,"name":"toolkit","full_name":"googleapis/toolkit","owner":{"login":"googleapis","id":16785467,"avatar_url":"https://avatars.githubusercontent.com/u/16785467?v=3","gravatar_id":"","url":"https://api.github.com/users/googleapis","html_url":"https://github.com/googleapis","followers_url":"https://api.github.com/users/googleapis/followers","following_url":"https://api.github.com/users/googleapis/following{/other_user}","gists_url":"https://api.github.com/users/googleapis/gists{/gist_id}","starred_url":"https://api.github.com/users/googleapis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/googleapis/subscriptions","organizations_url":"https://api.github.com/users/googleapis/orgs","repos_url":"https://api.github.com/users/googleapis/repos","events_url":"https://api.github.com/users/googleapis/events{/privacy}","received_events_url":"https://api.github.com/users/googleapis/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/googleapis/toolkit","description":"","fork":false,"url":"https://api.github.com/repos/googleapis/toolkit","forks_url":"https://api.github.com/repos/googleapis/toolkit/forks","keys_url":"https://api.github.com/repos/googleapis/toolkit/keys{/key_id}","collaborators_url":"https://api.github.com/repos/googleapis/toolkit/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/googleapis/toolkit/teams","hooks_url":"https://api.github.com/repos/googleapis/toolkit/hooks","issue_events_url":"https://api.github.com/repos/googleapis/toolkit/issues/events{/number}","events_url":"https://api.github.com/repos/googleapis/toolkit/events","assignees_url":"https://api.github.com/repos/googleapis/toolkit/assignees{/user}","branches_url":"https://api.github.com/repos/googleapis/toolkit/branches{/branch}","tags_url":"https://api.github.com/repos/googleapis/toolkit/tags","blobs_url":"https://api.github.com/repos/googleapis/toolkit/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/googleapis/toolkit/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/googleapis/toolkit/git/refs{/sha}","trees_url":"https://api.github.com/repos/googleapis/toolkit/git/trees{/sha}","statuses_url":"https://api.github.com/repos/googleapis/toolkit/statuses/{sha}","languages_url":"https://api.github.com/repos/googleapis/toolkit/languages","stargazers_url":"https://api.github.com/repos/googleapis/toolkit/stargazers","contributors_url":"https://api.github.com/repos/googleapis/toolkit/contributors","subscribers_url":"https://api.github.com/repos/googleapis/toolkit/subscribers","subscription_url":"https://api.github.com/repos/googleapis/toolkit/subscription","commits_url":"https://api.github.com/repos/googleapis/toolkit/commits{/sha}","git_commits_url":"https://api.github.com/repos/googleapis/toolkit/git/commits{/sha}","comments_url":"https://api.github.com/repos/googleapis/toolkit/comments{/number}","issue_comment_url":"https://api.github.com/repos/googleapis/toolkit/issues/comments{/number}","contents_url":"https://api.github.com/repos/googleapis/toolkit/contents/{+path}","compare_url":"https://api.github.com/repos/googleapis/toolkit/compare/{base}...{head}","merges_url":"https://api.github.com/repos/googleapis/toolkit/merges","archive_url":"https://api.github.com/repos/googleapis/toolkit/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/googleapis/toolkit/downloads","issues_url":"https://api.github.com/repos/googleapis/toolkit/issues{/number}","pulls_url":"https://api.github.com/repos/googleapis/toolkit/pulls{/number}","milestones_url":"https://api.github.com/repos/googleapis/toolkit/milestones{/number}","notifications_url":"https://api.github.com/repos/googleapis/toolkit/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/googleapis/toolkit/labels{/name}","releases_url":"https://api.github.com/repos/googleapis/toolkit/releases{/id}","deployments_url":"https://api.github.com/repos/googleapis/toolkit/deployments","created_at":"2016-04-18T18:58:04Z","updated_at":"2016-08-08T23:29:39Z","pushed_at":"2016-08-26T22:00:09Z","git_url":"git://github.com/googleapis/toolkit.git","ssh_url":"git@github.com:googleapis/toolkit.git","clone_url":"https://github.com/googleapis/toolkit.git","svn_url":"https://github.com/googleapis/toolkit","homepage":null,"size":9344,"stargazers_count":12,"watchers_count":12,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":19,"mirror_url":null,"open_issues_count":70,"forks":19,"open_issues":70,"watchers":12,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/googleapis/toolkit/pulls/429"},"html":{"href":"https://github.com/googleapis/toolkit/pull/429"},"issue":{"href":"https://api.github.com/repos/googleapis/toolkit/issues/429"},"comments":{"href":"https://api.github.com/repos/googleapis/toolkit/issues/429/comments"},"review_comments":{"href":"https://api.github.com/repos/googleapis/toolkit/pulls/429/comments"},"review_comment":{"href":"https://api.github.com/repos/googleapis/toolkit/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/googleapis/toolkit/pulls/429/commits"},"statuses":{"href":"https://api.github.com/repos/googleapis/toolkit/statuses/a0ea4d026ee0d24e691370f573deb3d4f8558cee"}}}}
{"actor":{"display_login":"vchudnov-g"}}