Pass the auth params to the front-end

The back-end provides a sets of authentication parameters, then pass to the Front-end SDK.

These parameters are signed by LG team.

APP_ID
APP_KEY
APP_URL
APP_UID

signature
timestamp

Heres a copy of sample code you could use to generate the parameters.

Sample codes

signature

When your webapge loads our SDK, the backend calculates a request signature using the sample codes we provide (with the same encryption algorithm), , and pass it to the front-end.

APP_UID (IMPORTANT!)

Every user from your platform must have a UID (Unique Identifier) so that we can recognize who the current user is.

In the meanwhile, we must make sure we transfer this UID data securely, that's why we require a two-step encryption.

  1. Encrypt the original user_id using your own encryption algorithm
  2. Encrypt again with LG encryption algorithm

1 Encrypt the original user_id using your own encryption algorithm

For example, your user table may look like this below

user_iduser_name
1James Bond
2Ethan Hunt

If we'd like to send data to LG of the first user - James Bond

Now let's encrypt the user_id(primary key)to make suer every single user has a unique identifier.

UID = sha1(user_id+salt)      (use salt to enhance the data security)
salt = "sfdsfsXXDD23901"       (random string)
UID = sha1(1+sfdsfsXXDD23901)
  =sha1("1sfdsfsXXDD23901")
  ="42fa5da9de51f2caa39217c4b8bece42ff6029cf"

Keep this UID confidential, do not make it public.

It'll be used for the further encryption, or in calling LG's APIs.

2. Encrypt again with LG encryption algorithm

Now, encrypt the UID you got from #1 again.

We expect you to encrypt it and eventually turn it to a UID like this below

Bd1ZZ5VO98z8Gf/z39m6RjSxhdOV9nW+8+6j9j+ZV2OOfXWwyChSJ3+xzRZulDyi:OTg3NjVmZWRjYmE0MzIxMA==

Sample codes

(Second encryption)。

Check out the encryptUID(uid).

String uid = "42fa5da9de51f2caa39217c4b8bece42ff6029cf";
System.out.println("Original UID: ");
System.out.println(uid);

String uidEncrypted = TBClient.encryptUID(uid);

System.out.println("Encrypted UID:");
System.out.println(uidEncrypted);

//Output
//Bd1ZZ5VO98z8Gf/z39m6RjSxhdOV9nW+8+6j9j+ZV2OOfXWwyChSJ3+xzRZulDyi:OTg3NjVmZWRjYmE0MzIxMA==
//this is just a sample output

APP_UID= "Bd1ZZ5VO98z8Gf/z39m6RjSxhdOV9nW+8+6j9j+ZV2OOfXWwyChSJ3+xzRZulDyi:OTg3NjVmZWRjYmE0MzIxMA=="

This is how you generate the APP_UID and then send it to the front-end SDK.

APP_UID can be decrypted when needed.

By doing #1 and #2, only LG knows how to decrypt the UID and your platform doesn't need to expose the original user_id.

This APP_UID is visible to public, and it's the UID the backend send to your front-end page.

This APP_UID can NOT be used in calling our APIs.