One Click Login
Take your app’s log-in form to the next level by letting your users sign in with a single tap of a button, avoiding complex passwords typing or password resets requests.
After tapping on the button the user will receive an email with an embedded smart link. Tapping on the email’s link, will take the user back to the app and loggin him in. For this to work, your app and your backend must integrate HOKO. Let’s start with your app.
Generating the lazy smart link for authentication
The user will enter his email and will tap on the Send Magic Link button.
This will request your server to send an email to the user’s account containing a lazy smart link
with the user’s authentication token, e.g. http://app.hoko.link/lazy?uri=%2Flogin%2Fq5w2e3r5t8y
.
Once the user opens the email and taps on the lazy smart link, it is going to request the generation of a smart link that will in fact redirect the user to your app.
Authenticating the token
For the application itself, all we need to do is map a login/:auth_token
route that calls a method
that is going to forward the authorization token to the backend to be validated.
@DeeplinkRoute("login/:auth_token")
public class AuthTokenLoginActivity extends Activity {
// Inject the auth. token in the deep link into this variable
@DeeplinkRouteParameter("auth_token")
private String mAuthToken;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.auth_token_login_view); // your view ID here
if (!Hoko.deeplinking().inject(this)) {
// If you manually launched this activity
} else {
// Validates the authentication token in the backend
LoginHelper.validateWithToken(mAuthToken, onSuccess);
}
}
protected void onSuccess() {
// Set's the user access token
_GLOBAL_AUTH_TOKEN = mAuthToken
// Display the right activity
startActivity(MyActivity)
}
}
If the response is positive, we can login the user and present the appropriate view. We are also going to save the current authorization token to be used on future requests.
More information
Need to know more about these subjects? Check the following pages for more information:
Check our frequently asked questions or send us a message if you can’t find what you are looking for. We’re always glad to hear from you and answer all your questions.