{"action":"opened","number":96,"pull_request":{"url":"https://api.github.com/repos/auth0/Auth0.Android/pulls/96","id":125672573,"html_url":"https://github.com/auth0/Auth0.Android/pull/96","diff_url":"https://github.com/auth0/Auth0.Android/pull/96.diff","patch_url":"https://github.com/auth0/Auth0.Android/pull/96.patch","issue_url":"https://api.github.com/repos/auth0/Auth0.Android/issues/96","number":96,"state":"open","locked":false,"title":"Add CredentialsManager and generic Storage","user":{"login":"lbalmaceda","id":3900123,"avatar_url":"https://avatars0.githubusercontent.com/u/3900123?v=3","gravatar_id":"","url":"https://api.github.com/users/lbalmaceda","html_url":"https://github.com/lbalmaceda","followers_url":"https://api.github.com/users/lbalmaceda/followers","following_url":"https://api.github.com/users/lbalmaceda/following{/other_user}","gists_url":"https://api.github.com/users/lbalmaceda/gists{/gist_id}","starred_url":"https://api.github.com/users/lbalmaceda/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lbalmaceda/subscriptions","organizations_url":"https://api.github.com/users/lbalmaceda/orgs","repos_url":"https://api.github.com/users/lbalmaceda/repos","events_url":"https://api.github.com/users/lbalmaceda/events{/privacy}","received_events_url":"https://api.github.com/users/lbalmaceda/received_events","type":"User","site_admin":false},"body":"A Credentials Manager will save credentials and retrieve them checking for valid values, expiration and even refreshing them if needed. If an error arises the user receives a `CredentialsManagerException`.\r\n\r\n### Usage\r\n1. **Instantiate the manager:** the Storage interface will let the user customize the persistence of the values.\r\n\r\n```java\r\nAuthenticationAPIClient authClient = //create auth client\r\nStorage storage = //create new storage\r\nCredentialsManager manager = new CredentialsManager(authClient, storage);\r\n```\r\n\r\n2. **Save credentials:** An `access_token` or `id_token` value is needed along with a valid `expires_in` value, if not it will raise `CredentialsManagerException`.\r\n\r\n```java\r\nCredentials credentials = //login to Auth0, i.e. by using the authClient\r\nmanager.setCredentials(credentials);\r\n```\r\n\r\n3. **Retrieve credentials:** If the `access_token` or `id_token` was not set it will raise `CredentialsManagerException`. If the saved credentials haven't expired they will be returned. If the credentials have expired and the `refresh_token` is null a `CredentialsManagerException` will be raised; else it will try to renew them by using the given authClient.\r\n\r\n```java\r\nmanager.getCredentials(new BaseCallback<Credentials, CredentialsManagerException>(){\r\n   public void onSuccess(Credentials credentials){\r\n      //success\r\n   }\r\n\r\n    public void onFailure(CredentialsManagerException error){\r\n      //error\r\n   }\r\n});\r\n```\r\n\r\n### TODO\r\n- [ ] Add tests\r\n- [ ] Provide an implementation of `Storage` with the library that uses `SharedPreferences`.\r\n- [ ] Javadoc + README\r\n","created_at":"2017-06-14T19:18:42Z","updated_at":"2017-06-14T19:18:42Z","closed_at":null,"merged_at":null,"merge_commit_sha":null,"assignee":null,"assignees":[],"requested_reviewers":[{"login":"nikolaseu","id":354336,"avatar_url":"https://avatars1.githubusercontent.com/u/354336?v=3","gravatar_id":"","url":"https://api.github.com/users/nikolaseu","html_url":"https://github.com/nikolaseu","followers_url":"https://api.github.com/users/nikolaseu/followers","following_url":"https://api.github.com/users/nikolaseu/following{/other_user}","gists_url":"https://api.github.com/users/nikolaseu/gists{/gist_id}","starred_url":"https://api.github.com/users/nikolaseu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nikolaseu/subscriptions","organizations_url":"https://api.github.com/users/nikolaseu/orgs","repos_url":"https://api.github.com/users/nikolaseu/repos","events_url":"https://api.github.com/users/nikolaseu/events{/privacy}","received_events_url":"https://api.github.com/users/nikolaseu/received_events","type":"User","site_admin":false}],"milestone":null,"commits_url":"https://api.github.com/repos/auth0/Auth0.Android/pulls/96/commits","review_comments_url":"https://api.github.com/repos/auth0/Auth0.Android/pulls/96/comments","review_comment_url":"https://api.github.com/repos/auth0/Auth0.Android/pulls/comments{/number}","comments_url":"https://api.github.com/repos/auth0/Auth0.Android/issues/96/comments","statuses_url":"https://api.github.com/repos/auth0/Auth0.Android/statuses/dcff045b6cd37dd146efa71d0bdb04099ae5a7be","head":{"label":"auth0:credentials-storage","ref":"credentials-storage","sha":"dcff045b6cd37dd146efa71d0bdb04099ae5a7be","user":{"login":"auth0","id":2824157,"avatar_url":"https://avatars2.githubusercontent.com/u/2824157?v=3","gravatar_id":"","url":"https://api.github.com/users/auth0","html_url":"https://github.com/auth0","followers_url":"https://api.github.com/users/auth0/followers","following_url":"https://api.github.com/users/auth0/following{/other_user}","gists_url":"https://api.github.com/users/auth0/gists{/gist_id}","starred_url":"https://api.github.com/users/auth0/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/auth0/subscriptions","organizations_url":"https://api.github.com/users/auth0/orgs","repos_url":"https://api.github.com/users/auth0/repos","events_url":"https://api.github.com/users/auth0/events{/privacy}","received_events_url":"https://api.github.com/users/auth0/received_events","type":"Organization","site_admin":false},"repo":{"id":62246133,"name":"Auth0.Android","full_name":"auth0/Auth0.Android","owner":{"login":"auth0","id":2824157,"avatar_url":"https://avatars2.githubusercontent.com/u/2824157?v=3","gravatar_id":"","url":"https://api.github.com/users/auth0","html_url":"https://github.com/auth0","followers_url":"https://api.github.com/users/auth0/followers","following_url":"https://api.github.com/users/auth0/following{/other_user}","gists_url":"https://api.github.com/users/auth0/gists{/gist_id}","starred_url":"https://api.github.com/users/auth0/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/auth0/subscriptions","organizations_url":"https://api.github.com/users/auth0/orgs","repos_url":"https://api.github.com/users/auth0/repos","events_url":"https://api.github.com/users/auth0/events{/privacy}","received_events_url":"https://api.github.com/users/auth0/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/auth0/Auth0.Android","description":"Android toolkit for Auth0 API","fork":false,"url":"https://api.github.com/repos/auth0/Auth0.Android","forks_url":"https://api.github.com/repos/auth0/Auth0.Android/forks","keys_url":"https://api.github.com/repos/auth0/Auth0.Android/keys{/key_id}","collaborators_url":"https://api.github.com/repos/auth0/Auth0.Android/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/auth0/Auth0.Android/teams","hooks_url":"https://api.github.com/repos/auth0/Auth0.Android/hooks","issue_events_url":"https://api.github.com/repos/auth0/Auth0.Android/issues/events{/number}","events_url":"https://api.github.com/repos/auth0/Auth0.Android/events","assignees_url":"https://api.github.com/repos/auth0/Auth0.Android/assignees{/user}","branches_url":"https://api.github.com/repos/auth0/Auth0.Android/branches{/branch}","tags_url":"https://api.github.com/repos/auth0/Auth0.Android/tags","blobs_url":"https://api.github.com/repos/auth0/Auth0.Android/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/auth0/Auth0.Android/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/auth0/Auth0.Android/git/refs{/sha}","trees_url":"https://api.github.com/repos/auth0/Auth0.Android/git/trees{/sha}","statuses_url":"https://api.github.com/repos/auth0/Auth0.Android/statuses/{sha}","languages_url":"https://api.github.com/repos/auth0/Auth0.Android/languages","stargazers_url":"https://api.github.com/repos/auth0/Auth0.Android/stargazers","contributors_url":"https://api.github.com/repos/auth0/Auth0.Android/contributors","subscribers_url":"https://api.github.com/repos/auth0/Auth0.Android/subscribers","subscription_url":"https://api.github.com/repos/auth0/Auth0.Android/subscription","commits_url":"https://api.github.com/repos/auth0/Auth0.Android/commits{/sha}","git_commits_url":"https://api.github.com/repos/auth0/Auth0.Android/git/commits{/sha}","comments_url":"https://api.github.com/repos/auth0/Auth0.Android/comments{/number}","issue_comment_url":"https://api.github.com/repos/auth0/Auth0.Android/issues/comments{/number}","contents_url":"https://api.github.com/repos/auth0/Auth0.Android/contents/{+path}","compare_url":"https://api.github.com/repos/auth0/Auth0.Android/compare/{base}...{head}","merges_url":"https://api.github.com/repos/auth0/Auth0.Android/merges","archive_url":"https://api.github.com/repos/auth0/Auth0.Android/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/auth0/Auth0.Android/downloads","issues_url":"https://api.github.com/repos/auth0/Auth0.Android/issues{/number}","pulls_url":"https://api.github.com/repos/auth0/Auth0.Android/pulls{/number}","milestones_url":"https://api.github.com/repos/auth0/Auth0.Android/milestones{/number}","notifications_url":"https://api.github.com/repos/auth0/Auth0.Android/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/auth0/Auth0.Android/labels{/name}","releases_url":"https://api.github.com/repos/auth0/Auth0.Android/releases{/id}","deployments_url":"https://api.github.com/repos/auth0/Auth0.Android/deployments","created_at":"2016-06-29T17:50:35Z","updated_at":"2017-06-08T20:43:05Z","pushed_at":"2017-06-14T18:57:22Z","git_url":"git://github.com/auth0/Auth0.Android.git","ssh_url":"git@github.com:auth0/Auth0.Android.git","clone_url":"https://github.com/auth0/Auth0.Android.git","svn_url":"https://github.com/auth0/Auth0.Android","homepage":"https://auth0.com","size":671,"stargazers_count":11,"watchers_count":11,"language":"Java","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":8,"mirror_url":null,"open_issues_count":3,"forks":8,"open_issues":3,"watchers":11,"default_branch":"master"}},"base":{"label":"auth0:master","ref":"master","sha":"853f717ebd837c7547e9a72338a93afa8bd4cd95","user":{"login":"auth0","id":2824157,"avatar_url":"https://avatars2.githubusercontent.com/u/2824157?v=3","gravatar_id":"","url":"https://api.github.com/users/auth0","html_url":"https://github.com/auth0","followers_url":"https://api.github.com/users/auth0/followers","following_url":"https://api.github.com/users/auth0/following{/other_user}","gists_url":"https://api.github.com/users/auth0/gists{/gist_id}","starred_url":"https://api.github.com/users/auth0/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/auth0/subscriptions","organizations_url":"https://api.github.com/users/auth0/orgs","repos_url":"https://api.github.com/users/auth0/repos","events_url":"https://api.github.com/users/auth0/events{/privacy}","received_events_url":"https://api.github.com/users/auth0/received_events","type":"Organization","site_admin":false},"repo":{"id":62246133,"name":"Auth0.Android","full_name":"auth0/Auth0.Android","owner":{"login":"auth0","id":2824157,"avatar_url":"https://avatars2.githubusercontent.com/u/2824157?v=3","gravatar_id":"","url":"https://api.github.com/users/auth0","html_url":"https://github.com/auth0","followers_url":"https://api.github.com/users/auth0/followers","following_url":"https://api.github.com/users/auth0/following{/other_user}","gists_url":"https://api.github.com/users/auth0/gists{/gist_id}","starred_url":"https://api.github.com/users/auth0/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/auth0/subscriptions","organizations_url":"https://api.github.com/users/auth0/orgs","repos_url":"https://api.github.com/users/auth0/repos","events_url":"https://api.github.com/users/auth0/events{/privacy}","received_events_url":"https://api.github.com/users/auth0/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/auth0/Auth0.Android","description":"Android toolkit for Auth0 API","fork":false,"url":"https://api.github.com/repos/auth0/Auth0.Android","forks_url":"https://api.github.com/repos/auth0/Auth0.Android/forks","keys_url":"https://api.github.com/repos/auth0/Auth0.Android/keys{/key_id}","collaborators_url":"https://api.github.com/repos/auth0/Auth0.Android/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/auth0/Auth0.Android/teams","hooks_url":"https://api.github.com/repos/auth0/Auth0.Android/hooks","issue_events_url":"https://api.github.com/repos/auth0/Auth0.Android/issues/events{/number}","events_url":"https://api.github.com/repos/auth0/Auth0.Android/events","assignees_url":"https://api.github.com/repos/auth0/Auth0.Android/assignees{/user}","branches_url":"https://api.github.com/repos/auth0/Auth0.Android/branches{/branch}","tags_url":"https://api.github.com/repos/auth0/Auth0.Android/tags","blobs_url":"https://api.github.com/repos/auth0/Auth0.Android/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/auth0/Auth0.Android/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/auth0/Auth0.Android/git/refs{/sha}","trees_url":"https://api.github.com/repos/auth0/Auth0.Android/git/trees{/sha}","statuses_url":"https://api.github.com/repos/auth0/Auth0.Android/statuses/{sha}","languages_url":"https://api.github.com/repos/auth0/Auth0.Android/languages","stargazers_url":"https://api.github.com/repos/auth0/Auth0.Android/stargazers","contributors_url":"https://api.github.com/repos/auth0/Auth0.Android/contributors","subscribers_url":"https://api.github.com/repos/auth0/Auth0.Android/subscribers","subscription_url":"https://api.github.com/repos/auth0/Auth0.Android/subscription","commits_url":"https://api.github.com/repos/auth0/Auth0.Android/commits{/sha}","git_commits_url":"https://api.github.com/repos/auth0/Auth0.Android/git/commits{/sha}","comments_url":"https://api.github.com/repos/auth0/Auth0.Android/comments{/number}","issue_comment_url":"https://api.github.com/repos/auth0/Auth0.Android/issues/comments{/number}","contents_url":"https://api.github.com/repos/auth0/Auth0.Android/contents/{+path}","compare_url":"https://api.github.com/repos/auth0/Auth0.Android/compare/{base}...{head}","merges_url":"https://api.github.com/repos/auth0/Auth0.Android/merges","archive_url":"https://api.github.com/repos/auth0/Auth0.Android/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/auth0/Auth0.Android/downloads","issues_url":"https://api.github.com/repos/auth0/Auth0.Android/issues{/number}","pulls_url":"https://api.github.com/repos/auth0/Auth0.Android/pulls{/number}","milestones_url":"https://api.github.com/repos/auth0/Auth0.Android/milestones{/number}","notifications_url":"https://api.github.com/repos/auth0/Auth0.Android/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/auth0/Auth0.Android/labels{/name}","releases_url":"https://api.github.com/repos/auth0/Auth0.Android/releases{/id}","deployments_url":"https://api.github.com/repos/auth0/Auth0.Android/deployments","created_at":"2016-06-29T17:50:35Z","updated_at":"2017-06-08T20:43:05Z","pushed_at":"2017-06-14T18:57:22Z","git_url":"git://github.com/auth0/Auth0.Android.git","ssh_url":"git@github.com:auth0/Auth0.Android.git","clone_url":"https://github.com/auth0/Auth0.Android.git","svn_url":"https://github.com/auth0/Auth0.Android","homepage":"https://auth0.com","size":671,"stargazers_count":11,"watchers_count":11,"language":"Java","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":8,"mirror_url":null,"open_issues_count":3,"forks":8,"open_issues":3,"watchers":11,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/auth0/Auth0.Android/pulls/96"},"html":{"href":"https://github.com/auth0/Auth0.Android/pull/96"},"issue":{"href":"https://api.github.com/repos/auth0/Auth0.Android/issues/96"},"comments":{"href":"https://api.github.com/repos/auth0/Auth0.Android/issues/96/comments"},"review_comments":{"href":"https://api.github.com/repos/auth0/Auth0.Android/pulls/96/comments"},"review_comment":{"href":"https://api.github.com/repos/auth0/Auth0.Android/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/auth0/Auth0.Android/pulls/96/commits"},"statuses":{"href":"https://api.github.com/repos/auth0/Auth0.Android/statuses/dcff045b6cd37dd146efa71d0bdb04099ae5a7be"}},"merged":false,"mergeable":null,"rebaseable":null,"mergeable_state":"unknown","merged_by":null,"comments":0,"review_comments":0,"maintainer_can_modify":false,"commits":1,"additions":115,"deletions":1,"changed_files":4}}
{"actor":{"display_login":"lbalmaceda"}}