# OneLogin Integration

## Registering applications with OneLogin

Refer to the following page on the OneLogin website for registering a new application.

[How To Set Up Your Own OneLogin App](https://breadbutter.io/how-to-set-up-onelogin-openid-connect/)

## Writing Mapping Function

Okta function for mapping the user profile is shown below.

```
public class OktaUserProfileMapper implements Loggable, TrilloFunction {

  public Object handle(ScriptParameter scriptParameter) {

    try {
      return _handle(scriptParameter);
    } catch (Exception e) {
      log().error("Failed", e);
      return Result.getFailedResult(e.getMessage());
    }
  }

  @SuppressWarnings("unchecked")
  private Object _handle(ScriptParameter scriptParameter) {
    Map<String, Object> idpUser = (Map<String, Object>)scriptParameter.getV();
    Map<String, Object> trilloUser = mapUserProfile(idpUser);
    return trilloUser;
  }
  
  private Map<String, Object> mapUserProfile(Map<String, Object> idpUser) {
    Map<String, Object> trilloUser = new LinkedHashMap<String, Object>();
    trilloUser.put("firstName", idpUser.get("given_name"));
    trilloUser.put("lastName", idpUser.get("family_name"));
    trilloUser.put("externalId", idpUser.get("sub"));
    trilloUser.put("emailAddress", idpUser.get("email"));
    return trilloUser;
 }
}
```
