https://github.com/agility/generate-agilitycms-ugc-auth-node
Generates authentication parameters for Agility UGC
https://github.com/agility/generate-agilitycms-ugc-auth-node
Last synced: 9 months ago
JSON representation
Generates authentication parameters for Agility UGC
- Host: GitHub
- URL: https://github.com/agility/generate-agilitycms-ugc-auth-node
- Owner: agility
- Created: 2020-06-12T13:45:27.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2020-06-12T13:51:38.000Z (almost 6 years ago)
- Last Synced: 2025-04-08T07:43:21.082Z (about 1 year ago)
- Language: JavaScript
- Size: 3.91 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# generate-agilitycms-ugc-auth-node
Generates authentication parameters for Agility UGC
## Example
```
const sha1 = require('sha1');
const UGCCREDENTIALS = {
key: "XXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXXX", //your UGC Public Key
pass: "XXXXXX-XXXX-XXXXX-XXXXX-XXXXXXXXXXX" //your UGC Password
}
const generateUGSettings = (UGCCREDENTIALS) => {
// SHA 1 of Seconds.ProfileID.SecretKey.AccessKey.Random
const jan12001 = new Date("Jan 1 2001");
const now = new Date();
const msecondsSinceJan12001 = now.getTime() - jan12001.getTime();
const secondsSinceJan12001 = Math.round(msecondsSinceJan12001 / 1000);
const random = Math.floor((Math.random() * 1000));
return {
'Url': 'https://ugc-ca.agilitycms.com/Agility-UGC-API-JSONP.svc',
'AccessKey': UGCCREDENTIALS.key, //the website API Access Key provided to you
'Seconds': secondsSinceJan12001, //is the number of seconds that have elapsed since Jan 1/2001.
'RandomNumber': random, //just a random number between 1-1000
'ProfileRecordID': '-1', //the profile record ID of the logged-in website user, -1 is anonymous
'AccessHash': sha1(`${secondsSinceJan12001}.-1.${UGCCREDENTIALS.pass}.${UGCCREDENTIALS.key}.${random}`) //The SHA hash of all the above variables (Seconds.ProfileID.SecretKey.AccessKey.Random)
};
}
console.log(generateUGSettings(UGCCREDENTIALS));
```
## How to Generate Credentials
Enter your `key` and `pass`. Then run the script.
```
> node index.js
```