Task #12075
Updated by Ondrej Grman almost 2 years ago
**Documentation** https://docs.google.com/document/d/1DRugdiiHMwcQSt4Z9AvDXZ1nep9rjWY3_2dP1Cn2SAA/edit **Credentials** ``` javascript export const EARN_ALLIANCE_SETTINGS = { clientId: '46a72344-dc3d-42b9-8372-498666caadb9', clientSecret: 'e9hnAaN520e2VbHCN9gUvckXZJntNvq6', gameId: 'b2a0d439-414a-4f2d-aa2d-c2eb8fac56ea', }; ``` **JS Example** ``` javascript private callCustomEvent(event: string) { const requestBody: EACustomEventRequestBody = { gameId: EARN_ALLIANCE_SETTINGS.gameId, event: event, address: this.walletAddres.value(), time: new Date().toISOString(), }; const headers = new HttpHeaders({ 'x-client-id': EARN_ALLIANCE_SETTINGS.clientId, 'x-timestapm': String(new Date().getMilliseconds()), 'x-signature': this.generateSignature(requestBody), }); return this.request.post( `${this.endpoint}${CUSTOM_EVENT_API}`, requestBody, { headers } ); } private generateSignature(body) { const ts = Date.now(); const message = `${EARN_ALLIANCE_SETTINGS.clientId}${ts}${JSON.stringify( body )}`; return HmacSHA256(message, EARN_ALLIANCE_SETTINGS.clientSecret).toString(); } ```