{"action":"created","issue":{"url":"https://api.github.com/repos/andretietz/retroauth/issues/43","repository_url":"https://api.github.com/repos/andretietz/retroauth","labels_url":"https://api.github.com/repos/andretietz/retroauth/issues/43/labels{/name}","comments_url":"https://api.github.com/repos/andretietz/retroauth/issues/43/comments","events_url":"https://api.github.com/repos/andretietz/retroauth/issues/43/events","html_url":"https://github.com/andretietz/retroauth/issues/43","id":175997545,"number":43,"title":"Doble login activity opened","user":{"login":"iagocanalejas","id":7596352,"avatar_url":"https://avatars.githubusercontent.com/u/7596352?v=3","gravatar_id":"","url":"https://api.github.com/users/iagocanalejas","html_url":"https://github.com/iagocanalejas","followers_url":"https://api.github.com/users/iagocanalejas/followers","following_url":"https://api.github.com/users/iagocanalejas/following{/other_user}","gists_url":"https://api.github.com/users/iagocanalejas/gists{/gist_id}","starred_url":"https://api.github.com/users/iagocanalejas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/iagocanalejas/subscriptions","organizations_url":"https://api.github.com/users/iagocanalejas/orgs","repos_url":"https://api.github.com/users/iagocanalejas/repos","events_url":"https://api.github.com/users/iagocanalejas/events{/privacy}","received_events_url":"https://api.github.com/users/iagocanalejas/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/andretietz/retroauth/labels/question","name":"question","color":"cc317c"}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":4,"created_at":"2016-09-09T12:28:31Z","updated_at":"2016-09-21T12:12:29Z","closed_at":null,"body":"I hope i could but i was no able to locate the error. \r\nSometimes the login activity is opened twice when the app starts.\r\nHere is my provider code(not so rare).\r\n```java\r\npublic class AccountProvider implements Provider<Account, AndroidTokenType, AndroidToken> {\r\n    private static final String TAG = \"AccountProvider\";\r\n\r\n    @Override\r\n    public Request authenticateRequest(Request request, AndroidToken androidToken) {\r\n        return request.newBuilder()\r\n                .header(\"Authorization\", \"Token \" + androidToken.token)\r\n                .build();\r\n    }\r\n\r\n    @Override\r\n    public boolean retryRequired(int i, Response response, final TokenStorage<Account, AndroidTokenType, AndroidToken> tokenStorage, final Account account, final AndroidTokenType androidTokenType, final AndroidToken androidToken) {\r\n        if (!response.isSuccessful()) {\r\n            if (response.code() == HttpURLConnection.HTTP_UNAUTHORIZED) {\r\n                BaseUser user = new BaseUser(account.name, androidToken.refreshToken);\r\n                Log.d(TAG, \"Retry Required: \" + account.name + \" \" + androidToken.refreshToken);\r\n                tokenStorage.removeToken(account, androidTokenType, androidToken);\r\n                try {\r\n                    retrofit2.Response<LoginWrapper> res = AccountGeneral.syncSignIn(user);\r\n                    if(res.isSuccessful()){\r\n                        tokenStorage.storeToken(account, androidTokenType, new AndroidToken(res.body().getToken(), androidToken.refreshToken));\r\n                        res.body().setPassword(androidToken.refreshToken);\r\n                        AccountGeneral.saveUser(account, res.body().getUser());\r\n                        return true;\r\n                    }\r\n                } catch (IOException e) {\r\n                    e.printStackTrace();\r\n                } finally {\r\n                    response.close();\r\n                }\r\n            }\r\n            Log.d(TAG, \"retryRequired: \" + response.code());\r\n        }\r\n        return false;\r\n    }\r\n}\r\n```\r\n\r\nMy ActivityLogin(it use fragments so i handle the actions in methods onSuccess and onError)\r\n```java\r\npublic class ActivityLogin extends AuthenticationActivity implements ILoginInteractionListener{\r\n\r\n    private static final String TAG = \"ActivityLogin\";\r\n\r\n    @Override\r\n    protected void onCreate(Bundle savedInstanceState) {\r\n        super.onCreate(savedInstanceState);\r\n        setContentView(R.layout.activity_login);\r\n\r\n        getSupportFragmentManager().beginTransaction()\r\n                .replace(R.id.login_content, new FragmentLogin(), FragmentLogin.TAG).commit();\r\n    }\r\n\r\n    @Override\r\n    public void onBackPressed() {\r\n        if (getSupportFragmentManager().findFragmentByTag(FragmentSignUp.TAG) != null) {\r\n            getSupportFragmentManager().popBackStack();\r\n        }else{\r\n            finish();\r\n        }\r\n    }\r\n\r\n    @Override\r\n    public void onSuccess(LoginWrapper loginWrapper) {\r\n        Log.d(TAG, \"onSuccess: \" + loginWrapper.getUser().getUsername());\r\n        Account account = createOrGetAccount(loginWrapper.getUser().getUsername());\r\n        storeToken(account, getString(R.string.authentication_TOKEN), loginWrapper.getToken(), loginWrapper.getUser().getPassword());\r\n        AccountGeneral.saveUser(account, loginWrapper.getUser());\r\n        finalizeAuthentication(account);\r\n    }\r\n\r\n    @Override\r\n    public void onError() {\r\n        Log.d(TAG, \"onError\");\r\n        ILoginFragment f = (ILoginFragment) ((getSupportFragmentManager().findFragmentByTag(FragmentLogin.TAG) != null)\r\n                ? getSupportFragmentManager().findFragmentByTag(FragmentLogin.TAG)\r\n                : getSupportFragmentManager().findFragmentByTag(FragmentSignUp.TAG));\r\n\r\n        if (f != null) {\r\n            f.onErrorLogin();\r\n        }\r\n    }\r\n}\r\n```\r\nAsk for more details if u need it.\r\n\r\nThank you for help and nice library :+1: "},"comment":{"url":"https://api.github.com/repos/andretietz/retroauth/issues/comments/248593054","html_url":"https://github.com/andretietz/retroauth/issues/43#issuecomment-248593054","issue_url":"https://api.github.com/repos/andretietz/retroauth/issues/43","id":248593054,"user":{"login":"iagocanalejas","id":7596352,"avatar_url":"https://avatars.githubusercontent.com/u/7596352?v=3","gravatar_id":"","url":"https://api.github.com/users/iagocanalejas","html_url":"https://github.com/iagocanalejas","followers_url":"https://api.github.com/users/iagocanalejas/followers","following_url":"https://api.github.com/users/iagocanalejas/following{/other_user}","gists_url":"https://api.github.com/users/iagocanalejas/gists{/gist_id}","starred_url":"https://api.github.com/users/iagocanalejas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/iagocanalejas/subscriptions","organizations_url":"https://api.github.com/users/iagocanalejas/orgs","repos_url":"https://api.github.com/users/iagocanalejas/repos","events_url":"https://api.github.com/users/iagocanalejas/events{/privacy}","received_events_url":"https://api.github.com/users/iagocanalejas/received_events","type":"User","site_admin":false},"created_at":"2016-09-21T12:12:29Z","updated_at":"2016-09-21T12:12:29Z","body":"Ok i will take a lock on my requests and see if i'm sending two. Thanks for answer, tell u in a few hours."}}
{"actor":{"display_login":"iagocanalejas"}}