moh3a/ae_sdk

AESystemClient.generateToken not working due to nuance

UnsupportedCallbackException opened this issue · 1 comments

AESystemClient.generateToken not working due to nuance with new&migrated API signing

/auth/token/create is new API so according to documentation (step #3) you have to create string in next format {api_path}{sorted_key_value_without_method}

Actually I copied if statement from AEBaseClient.call method and it works well for me

protected sign(params: any): string {
    const p = {...params};
    let basestring = '';
    if (p.method.includes("/")) {
      basestring = p.method;
      delete p.method;
    };

    basestring += Object.keys(p).sort().map(key => key + p[key as keyof typeof p]).join('');
    
    return createHmac("sha256", this.app_secret, { encoding: "utf-8" })
      .update(basestring)
      .digest("hex")
      .toUpperCase();
  }

Also really appreciate your intention and solution

moh3a commented

Thank you, it seems I forgot to update the sign method to support the new API signing format. It should be fixed by the next patch