{"action":"created","issue":{"url":"https://api.github.com/repos/Grover-c13/PokeGOAPI-Java/issues/380","repository_url":"https://api.github.com/repos/Grover-c13/PokeGOAPI-Java","labels_url":"https://api.github.com/repos/Grover-c13/PokeGOAPI-Java/issues/380/labels{/name}","comments_url":"https://api.github.com/repos/Grover-c13/PokeGOAPI-Java/issues/380/comments","events_url":"https://api.github.com/repos/Grover-c13/PokeGOAPI-Java/issues/380/events","html_url":"https://github.com/Grover-c13/PokeGOAPI-Java/issues/380","id":168492923,"number":380,"title":"Get credentials access token programmatically from login URL","user":{"login":"meher19","id":2823882,"avatar_url":"https://avatars.githubusercontent.com/u/2823882?v=3","gravatar_id":"","url":"https://api.github.com/users/meher19","html_url":"https://github.com/meher19","followers_url":"https://api.github.com/users/meher19/followers","following_url":"https://api.github.com/users/meher19/following{/other_user}","gists_url":"https://api.github.com/users/meher19/gists{/gist_id}","starred_url":"https://api.github.com/users/meher19/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/meher19/subscriptions","organizations_url":"https://api.github.com/users/meher19/orgs","repos_url":"https://api.github.com/users/meher19/repos","events_url":"https://api.github.com/users/meher19/events{/privacy}","received_events_url":"https://api.github.com/users/meher19/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":6,"created_at":"2016-07-30T23:50:48Z","updated_at":"2016-07-31T00:39:53Z","closed_at":null,"body":"Hello,\r\n\r\nHow to get the access token without using the allow button in browser and copy/paste manually the token ?\r\nThe authentification working well for me, i'm just looking for to make it full automatic, the user have just to clic only one button when he opens the app.\r\n\r\nThis is my code : \r\n```\r\nGoogleUserCredentialProvider provider = new GoogleUserCredentialProvider(httpClient);\r\n\r\n        // in this url, you will get a code for the google account that is logged\r\n        System.out.println(\"Please go to \" + GoogleUserCredentialProvider.LOGIN_URL);\r\n        System.out.println(\"Enter authorisation code:\");\r\n\r\n        // Ask the user to enter it in the standart input\r\n        Scanner sc = new Scanner(System.in);\r\n        String access = sc.nextLine();\r\n\r\n\r\n        // we should be able to login with this token\r\n        provider.login(access);\r\n\r\n        /**\r\n         * After this, if you do not want to re-authorize the google account every time,\r\n         * you will need to store the refresh_token that you can get the first time with provider.getRefreshToken()\r\n         * ! The API does not store the refresh token for you !\r\n         * log in using the refresh token like this :\r\n         */\r\n        PokemonGo go = new PokemonGo(new GoogleUserCredentialProvider(httpClient, provider.getRefreshToken(), new PokeTime()), httpClient);\r\n```\r\n\r\nThanks."},"comment":{"url":"https://api.github.com/repos/Grover-c13/PokeGOAPI-Java/issues/comments/236399397","html_url":"https://github.com/Grover-c13/PokeGOAPI-Java/issues/380#issuecomment-236399397","issue_url":"https://api.github.com/repos/Grover-c13/PokeGOAPI-Java/issues/380","id":236399397,"user":{"login":"FabianTerhorst","id":3597376,"avatar_url":"https://avatars.githubusercontent.com/u/3597376?v=3","gravatar_id":"","url":"https://api.github.com/users/FabianTerhorst","html_url":"https://github.com/FabianTerhorst","followers_url":"https://api.github.com/users/FabianTerhorst/followers","following_url":"https://api.github.com/users/FabianTerhorst/following{/other_user}","gists_url":"https://api.github.com/users/FabianTerhorst/gists{/gist_id}","starred_url":"https://api.github.com/users/FabianTerhorst/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/FabianTerhorst/subscriptions","organizations_url":"https://api.github.com/users/FabianTerhorst/orgs","repos_url":"https://api.github.com/users/FabianTerhorst/repos","events_url":"https://api.github.com/users/FabianTerhorst/events{/privacy}","received_events_url":"https://api.github.com/users/FabianTerhorst/received_events","type":"User","site_admin":false},"created_at":"2016-07-31T00:39:52Z","updated_at":"2016-07-31T00:39:52Z","body":"but maybe it could work. i don´t see any api key related stuff in:\r\n\r\n```\r\nstatic final int REQUEST_CODE_PICK_ACCOUNT = 1000;\r\n\r\nprivate void pickUserAccount() {\r\n    String[] accountTypes = new String[]{\"com.google\"};\r\n    Intent intent = AccountPicker.newChooseAccountIntent(null, null,\r\n            accountTypes, false, null, null, null, null);\r\n    startActivityForResult(intent, REQUEST_CODE_PICK_ACCOUNT);\r\n}\r\n```\r\n\r\nand \r\n\r\n```\r\nString mEmail; // Received from newChooseAccountIntent(); passed to getToken()\r\n\r\n@Override\r\nprotected void onActivityResult(int requestCode, int resultCode, Intent data) {\r\n    if (requestCode == REQUEST_CODE_PICK_ACCOUNT) {\r\n        // Receiving a result from the AccountPicker\r\n        if (resultCode == RESULT_OK) {\r\n            mEmail = data.getStringExtra(AccountManager.KEY_ACCOUNT_NAME);\r\n            // With the account name acquired, go get the auth token\r\n            getUsername();\r\n        } else if (resultCode == RESULT_CANCELED) {\r\n            // The account picker dialog closed without selecting an account.\r\n            // Notify users that they must pick an account to proceed.\r\n            Toast.makeText(this, R.string.pick_account, Toast.LENGTH_SHORT).show();\r\n        }\r\n    }\r\n    // Handle the result from exceptions\r\n    ...\r\n}\r\n\r\n```"}}
{"actor":{"display_login":"FabianTerhorst"}}