Generates the token from given credentials. Two types of authentication credentials are supported.
1. Authenticate using password - This requires username and password to be provided, and type set to "password".
2. Authenticate using App Secret - This requires appId and appSecret to be provided, and type set to "application".