{"action":"created","comment":{"url":"https://api.github.com/repos/bandwidthcom/java-bandwidth/pulls/comments/32724593","id":32724593,"diff_hunk":"@@ -196,6 +200,27 @@ public void setCredentials(final String userId, final String apiToken, final Str\n         usersUri = String.format(BandwidthConstants.USERS_URI_PATH, userId);\n         this.token = apiToken;\n         this.secret = apiSecret;\n+\n+        validateCredentials();\n+    }\n+\n+    /**\n+     * Validate if the credentials are set and has access to catapult\n+     */\n+    private static void validateCredentials() {\n+        try {\n+            Account.get().getAccountInfo();\n+        } catch (Exception e) {\n+            if (e instanceof AppPlatformException) {\n+                AppPlatformException appEx = (AppPlatformException) e;\n+\n+                if (appEx.getStatus() == 401){","path":"src/main/java/com/bandwidth/sdk/BandwidthClient.java","position":61,"original_position":61,"commit_id":"aaf41fc6a3e1cf4c25835715b900bb4906681e9a","original_commit_id":"aaf41fc6a3e1cf4c25835715b900bb4906681e9a","user":{"login":"leonardo-daitan","id":1799971,"avatar_url":"https://avatars.githubusercontent.com/u/1799971?v=3","gravatar_id":"","url":"https://api.github.com/users/leonardo-daitan","html_url":"https://github.com/leonardo-daitan","followers_url":"https://api.github.com/users/leonardo-daitan/followers","following_url":"https://api.github.com/users/leonardo-daitan/following{/other_user}","gists_url":"https://api.github.com/users/leonardo-daitan/gists{/gist_id}","starred_url":"https://api.github.com/users/leonardo-daitan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/leonardo-daitan/subscriptions","organizations_url":"https://api.github.com/users/leonardo-daitan/orgs","repos_url":"https://api.github.com/users/leonardo-daitan/repos","events_url":"https://api.github.com/users/leonardo-daitan/events{/privacy}","received_events_url":"https://api.github.com/users/leonardo-daitan/received_events","type":"User","site_admin":false},"body":"If 400 is returned, it means that the credentials are invalid not missing, isn't it?","created_at":"2015-06-18T12:38:07Z","updated_at":"2015-06-18T12:38:07Z","html_url":"https://github.com/bandwidthcom/java-bandwidth/pull/29#discussion_r32724593","pull_request_url":"https://api.github.com/repos/bandwidthcom/java-bandwidth/pulls/29","_links":{"self":{"href":"https://api.github.com/repos/bandwidthcom/java-bandwidth/pulls/comments/32724593"},"html":{"href":"https://github.com/bandwidthcom/java-bandwidth/pull/29#discussion_r32724593"},"pull_request":{"href":"https://api.github.com/repos/bandwidthcom/java-bandwidth/pulls/29"}}},"pull_request":{"url":"https://api.github.com/repos/bandwidthcom/java-bandwidth/pulls/29","id":38000893,"html_url":"https://github.com/bandwidthcom/java-bandwidth/pull/29","diff_url":"https://github.com/bandwidthcom/java-bandwidth/pull/29.diff","patch_url":"https://github.com/bandwidthcom/java-bandwidth/pull/29.patch","issue_url":"https://api.github.com/repos/bandwidthcom/java-bandwidth/issues/29","number":29,"state":"open","locked":false,"title":"Implementation of wrong credentials exception","user":{"login":"lnunes-daitan","id":12140873,"avatar_url":"https://avatars.githubusercontent.com/u/12140873?v=3","gravatar_id":"","url":"https://api.github.com/users/lnunes-daitan","html_url":"https://github.com/lnunes-daitan","followers_url":"https://api.github.com/users/lnunes-daitan/followers","following_url":"https://api.github.com/users/lnunes-daitan/following{/other_user}","gists_url":"https://api.github.com/users/lnunes-daitan/gists{/gist_id}","starred_url":"https://api.github.com/users/lnunes-daitan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lnunes-daitan/subscriptions","organizations_url":"https://api.github.com/users/lnunes-daitan/orgs","repos_url":"https://api.github.com/users/lnunes-daitan/repos","events_url":"https://api.github.com/users/lnunes-daitan/events{/privacy}","received_events_url":"https://api.github.com/users/lnunes-daitan/received_events","type":"User","site_admin":false},"body":"On getInstance() and setCredentials, added a call to getAccountInfo to validate if set credentials are correct","created_at":"2015-06-18T12:27:53Z","updated_at":"2015-06-18T12:38:07Z","closed_at":null,"merged_at":null,"merge_commit_sha":"54f71ae62d589f551ab4b94abe2e932d7efbb7fe","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/bandwidthcom/java-bandwidth/pulls/29/commits","review_comments_url":"https://api.github.com/repos/bandwidthcom/java-bandwidth/pulls/29/comments","review_comment_url":"https://api.github.com/repos/bandwidthcom/java-bandwidth/pulls/comments{/number}","comments_url":"https://api.github.com/repos/bandwidthcom/java-bandwidth/issues/29/comments","statuses_url":"https://api.github.com/repos/bandwidthcom/java-bandwidth/statuses/aaf41fc6a3e1cf4c25835715b900bb4906681e9a","head":{"label":"bandwidthcom:missing_creds_exception","ref":"missing_creds_exception","sha":"aaf41fc6a3e1cf4c25835715b900bb4906681e9a","user":{"login":"bandwidthcom","id":663479,"avatar_url":"https://avatars.githubusercontent.com/u/663479?v=3","gravatar_id":"","url":"https://api.github.com/users/bandwidthcom","html_url":"https://github.com/bandwidthcom","followers_url":"https://api.github.com/users/bandwidthcom/followers","following_url":"https://api.github.com/users/bandwidthcom/following{/other_user}","gists_url":"https://api.github.com/users/bandwidthcom/gists{/gist_id}","starred_url":"https://api.github.com/users/bandwidthcom/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bandwidthcom/subscriptions","organizations_url":"https://api.github.com/users/bandwidthcom/orgs","repos_url":"https://api.github.com/users/bandwidthcom/repos","events_url":"https://api.github.com/users/bandwidthcom/events{/privacy}","received_events_url":"https://api.github.com/users/bandwidthcom/received_events","type":"Organization","site_admin":false},"repo":{"id":22510485,"name":"java-bandwidth","full_name":"bandwidthcom/java-bandwidth","owner":{"login":"bandwidthcom","id":663479,"avatar_url":"https://avatars.githubusercontent.com/u/663479?v=3","gravatar_id":"","url":"https://api.github.com/users/bandwidthcom","html_url":"https://github.com/bandwidthcom","followers_url":"https://api.github.com/users/bandwidthcom/followers","following_url":"https://api.github.com/users/bandwidthcom/following{/other_user}","gists_url":"https://api.github.com/users/bandwidthcom/gists{/gist_id}","starred_url":"https://api.github.com/users/bandwidthcom/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bandwidthcom/subscriptions","organizations_url":"https://api.github.com/users/bandwidthcom/orgs","repos_url":"https://api.github.com/users/bandwidthcom/repos","events_url":"https://api.github.com/users/bandwidthcom/events{/privacy}","received_events_url":"https://api.github.com/users/bandwidthcom/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/bandwidthcom/java-bandwidth","description":"Java SDK for use with the Catapult API","fork":false,"url":"https://api.github.com/repos/bandwidthcom/java-bandwidth","forks_url":"https://api.github.com/repos/bandwidthcom/java-bandwidth/forks","keys_url":"https://api.github.com/repos/bandwidthcom/java-bandwidth/keys{/key_id}","collaborators_url":"https://api.github.com/repos/bandwidthcom/java-bandwidth/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/bandwidthcom/java-bandwidth/teams","hooks_url":"https://api.github.com/repos/bandwidthcom/java-bandwidth/hooks","issue_events_url":"https://api.github.com/repos/bandwidthcom/java-bandwidth/issues/events{/number}","events_url":"https://api.github.com/repos/bandwidthcom/java-bandwidth/events","assignees_url":"https://api.github.com/repos/bandwidthcom/java-bandwidth/assignees{/user}","branches_url":"https://api.github.com/repos/bandwidthcom/java-bandwidth/branches{/branch}","tags_url":"https://api.github.com/repos/bandwidthcom/java-bandwidth/tags","blobs_url":"https://api.github.com/repos/bandwidthcom/java-bandwidth/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/bandwidthcom/java-bandwidth/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/bandwidthcom/java-bandwidth/git/refs{/sha}","trees_url":"https://api.github.com/repos/bandwidthcom/java-bandwidth/git/trees{/sha}","statuses_url":"https://api.github.com/repos/bandwidthcom/java-bandwidth/statuses/{sha}","languages_url":"https://api.github.com/repos/bandwidthcom/java-bandwidth/languages","stargazers_url":"https://api.github.com/repos/bandwidthcom/java-bandwidth/stargazers","contributors_url":"https://api.github.com/repos/bandwidthcom/java-bandwidth/contributors","subscribers_url":"https://api.github.com/repos/bandwidthcom/java-bandwidth/subscribers","subscription_url":"https://api.github.com/repos/bandwidthcom/java-bandwidth/subscription","commits_url":"https://api.github.com/repos/bandwidthcom/java-bandwidth/commits{/sha}","git_commits_url":"https://api.github.com/repos/bandwidthcom/java-bandwidth/git/commits{/sha}","comments_url":"https://api.github.com/repos/bandwidthcom/java-bandwidth/comments{/number}","issue_comment_url":"https://api.github.com/repos/bandwidthcom/java-bandwidth/issues/comments{/number}","contents_url":"https://api.github.com/repos/bandwidthcom/java-bandwidth/contents/{+path}","compare_url":"https://api.github.com/repos/bandwidthcom/java-bandwidth/compare/{base}...{head}","merges_url":"https://api.github.com/repos/bandwidthcom/java-bandwidth/merges","archive_url":"https://api.github.com/repos/bandwidthcom/java-bandwidth/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/bandwidthcom/java-bandwidth/downloads","issues_url":"https://api.github.com/repos/bandwidthcom/java-bandwidth/issues{/number}","pulls_url":"https://api.github.com/repos/bandwidthcom/java-bandwidth/pulls{/number}","milestones_url":"https://api.github.com/repos/bandwidthcom/java-bandwidth/milestones{/number}","notifications_url":"https://api.github.com/repos/bandwidthcom/java-bandwidth/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/bandwidthcom/java-bandwidth/labels{/name}","releases_url":"https://api.github.com/repos/bandwidthcom/java-bandwidth/releases{/id}","created_at":"2014-08-01T13:19:48Z","updated_at":"2015-06-09T23:04:42Z","pushed_at":"2015-06-18T12:30:22Z","git_url":"git://github.com/bandwidthcom/java-bandwidth.git","ssh_url":"git@github.com:bandwidthcom/java-bandwidth.git","clone_url":"https://github.com/bandwidthcom/java-bandwidth.git","svn_url":"https://github.com/bandwidthcom/java-bandwidth","homepage":null,"size":4008,"stargazers_count":2,"watchers_count":2,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":1,"forks":1,"open_issues":1,"watchers":2,"default_branch":"master"}},"base":{"label":"bandwidthcom:master","ref":"master","sha":"ebfc2d076423ef45db877f3f81a30bc4ad4e684e","user":{"login":"bandwidthcom","id":663479,"avatar_url":"https://avatars.githubusercontent.com/u/663479?v=3","gravatar_id":"","url":"https://api.github.com/users/bandwidthcom","html_url":"https://github.com/bandwidthcom","followers_url":"https://api.github.com/users/bandwidthcom/followers","following_url":"https://api.github.com/users/bandwidthcom/following{/other_user}","gists_url":"https://api.github.com/users/bandwidthcom/gists{/gist_id}","starred_url":"https://api.github.com/users/bandwidthcom/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bandwidthcom/subscriptions","organizations_url":"https://api.github.com/users/bandwidthcom/orgs","repos_url":"https://api.github.com/users/bandwidthcom/repos","events_url":"https://api.github.com/users/bandwidthcom/events{/privacy}","received_events_url":"https://api.github.com/users/bandwidthcom/received_events","type":"Organization","site_admin":false},"repo":{"id":22510485,"name":"java-bandwidth","full_name":"bandwidthcom/java-bandwidth","owner":{"login":"bandwidthcom","id":663479,"avatar_url":"https://avatars.githubusercontent.com/u/663479?v=3","gravatar_id":"","url":"https://api.github.com/users/bandwidthcom","html_url":"https://github.com/bandwidthcom","followers_url":"https://api.github.com/users/bandwidthcom/followers","following_url":"https://api.github.com/users/bandwidthcom/following{/other_user}","gists_url":"https://api.github.com/users/bandwidthcom/gists{/gist_id}","starred_url":"https://api.github.com/users/bandwidthcom/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bandwidthcom/subscriptions","organizations_url":"https://api.github.com/users/bandwidthcom/orgs","repos_url":"https://api.github.com/users/bandwidthcom/repos","events_url":"https://api.github.com/users/bandwidthcom/events{/privacy}","received_events_url":"https://api.github.com/users/bandwidthcom/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/bandwidthcom/java-bandwidth","description":"Java SDK for use with the Catapult API","fork":false,"url":"https://api.github.com/repos/bandwidthcom/java-bandwidth","forks_url":"https://api.github.com/repos/bandwidthcom/java-bandwidth/forks","keys_url":"https://api.github.com/repos/bandwidthcom/java-bandwidth/keys{/key_id}","collaborators_url":"https://api.github.com/repos/bandwidthcom/java-bandwidth/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/bandwidthcom/java-bandwidth/teams","hooks_url":"https://api.github.com/repos/bandwidthcom/java-bandwidth/hooks","issue_events_url":"https://api.github.com/repos/bandwidthcom/java-bandwidth/issues/events{/number}","events_url":"https://api.github.com/repos/bandwidthcom/java-bandwidth/events","assignees_url":"https://api.github.com/repos/bandwidthcom/java-bandwidth/assignees{/user}","branches_url":"https://api.github.com/repos/bandwidthcom/java-bandwidth/branches{/branch}","tags_url":"https://api.github.com/repos/bandwidthcom/java-bandwidth/tags","blobs_url":"https://api.github.com/repos/bandwidthcom/java-bandwidth/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/bandwidthcom/java-bandwidth/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/bandwidthcom/java-bandwidth/git/refs{/sha}","trees_url":"https://api.github.com/repos/bandwidthcom/java-bandwidth/git/trees{/sha}","statuses_url":"https://api.github.com/repos/bandwidthcom/java-bandwidth/statuses/{sha}","languages_url":"https://api.github.com/repos/bandwidthcom/java-bandwidth/languages","stargazers_url":"https://api.github.com/repos/bandwidthcom/java-bandwidth/stargazers","contributors_url":"https://api.github.com/repos/bandwidthcom/java-bandwidth/contributors","subscribers_url":"https://api.github.com/repos/bandwidthcom/java-bandwidth/subscribers","subscription_url":"https://api.github.com/repos/bandwidthcom/java-bandwidth/subscription","commits_url":"https://api.github.com/repos/bandwidthcom/java-bandwidth/commits{/sha}","git_commits_url":"https://api.github.com/repos/bandwidthcom/java-bandwidth/git/commits{/sha}","comments_url":"https://api.github.com/repos/bandwidthcom/java-bandwidth/comments{/number}","issue_comment_url":"https://api.github.com/repos/bandwidthcom/java-bandwidth/issues/comments{/number}","contents_url":"https://api.github.com/repos/bandwidthcom/java-bandwidth/contents/{+path}","compare_url":"https://api.github.com/repos/bandwidthcom/java-bandwidth/compare/{base}...{head}","merges_url":"https://api.github.com/repos/bandwidthcom/java-bandwidth/merges","archive_url":"https://api.github.com/repos/bandwidthcom/java-bandwidth/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/bandwidthcom/java-bandwidth/downloads","issues_url":"https://api.github.com/repos/bandwidthcom/java-bandwidth/issues{/number}","pulls_url":"https://api.github.com/repos/bandwidthcom/java-bandwidth/pulls{/number}","milestones_url":"https://api.github.com/repos/bandwidthcom/java-bandwidth/milestones{/number}","notifications_url":"https://api.github.com/repos/bandwidthcom/java-bandwidth/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/bandwidthcom/java-bandwidth/labels{/name}","releases_url":"https://api.github.com/repos/bandwidthcom/java-bandwidth/releases{/id}","created_at":"2014-08-01T13:19:48Z","updated_at":"2015-06-09T23:04:42Z","pushed_at":"2015-06-18T12:30:22Z","git_url":"git://github.com/bandwidthcom/java-bandwidth.git","ssh_url":"git@github.com:bandwidthcom/java-bandwidth.git","clone_url":"https://github.com/bandwidthcom/java-bandwidth.git","svn_url":"https://github.com/bandwidthcom/java-bandwidth","homepage":null,"size":4008,"stargazers_count":2,"watchers_count":2,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":1,"forks":1,"open_issues":1,"watchers":2,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/bandwidthcom/java-bandwidth/pulls/29"},"html":{"href":"https://github.com/bandwidthcom/java-bandwidth/pull/29"},"issue":{"href":"https://api.github.com/repos/bandwidthcom/java-bandwidth/issues/29"},"comments":{"href":"https://api.github.com/repos/bandwidthcom/java-bandwidth/issues/29/comments"},"review_comments":{"href":"https://api.github.com/repos/bandwidthcom/java-bandwidth/pulls/29/comments"},"review_comment":{"href":"https://api.github.com/repos/bandwidthcom/java-bandwidth/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/bandwidthcom/java-bandwidth/pulls/29/commits"},"statuses":{"href":"https://api.github.com/repos/bandwidthcom/java-bandwidth/statuses/aaf41fc6a3e1cf4c25835715b900bb4906681e9a"}}}}