SSO for android app with zendesk

440 views Asked by At

I need some help with the Single Sign On for android app with Zendesk. It uses the JSON Web Tokens and I do not have any ideas how to implement those in my android project. The Zendesk team have provided some sample jwt in different languages but I do not know how to use them and execute those.

1

There are 1 answers

0
Yazon2006 On

First of all if you want to use JWT authentification you must have back-end for your project with users database. And on this back-end must be implemented JWT endpoint. It is URL which using by your app to verificate user.

So if you have all this stuff then go to Zendesk admin panel. On left side choose "Mobile SDK" then create new mobile app. It would generate you codes for initialization Zendesk in your app. Like this:

ZendeskConfig.INSTANCE.init(this, "https://yoursite.zendesk.com",  "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", "mobile_sdk_client_xxxxxxxxxxxxxxxxx", new ZendeskCallback<String>() {


@Override
  public void onSuccess(String result) {

  }

  @Override
  public void onError(ErrorResponse error) {

  }

});

After such initialization you can use anonymus identifying of user like this:

Identity anonymousIdentity = new AnonymousIdentity.Builder()
                        .withEmailIdentifier(authManager.getClient().email)
                        .withNameIdentifier(authManager.getClient().firstName)
                        .build();

                ZendeskConfig.INSTANCE.setIdentity(anonymousIdentity);

But JWT authentification would not work until you enter JWT endpoint in Admin panel. There are you can see settings of which type authorization use right exactly where we added new app in Zendesk but little a bit below.

So you choose Authentication method - JWT. Entering endpoint on your site which using for authentification of user. Where to get such URL? Ask about it in your back-end guys. It's not android possibility.

After such long way manipulations you can use now JWT authentification like this:

Identity jwtUserIdentity = new JwtIdentity("JWT User Identifier");
ZendeskConfig.INSTANCE.setIdentity(jwtUserIdentity);

Remove "JWT User Identifier" and use e-mail of user for example. But zendesk not recommend using something predictable like email or user id. Better to use user's access token that the app will have after your user logs in. But in test example from zendesk they are using exactly e-mail =)

If I explained something not very clear you can read documentation and see example of android app here:

How to configure app

How to configure it in zendesk

Example app