GitHub user waiphyodev added a comment to the discussion: 401 error in
cloudstack createUser rest api
My bad! Thanks for all your helps.
(error) params => get signature for params => encode signature
(success) params => encode params => get signature for encoded params => encode
signature
```javascript
const params = {
...queryParams, // parameters like command
apikey: <api-key>,
response: "json",
};
const sortedKeys = Object.keys(params)
.map((k) => k.toLowerCase())
.sort();
const encodedSortedQuery = sortedKeys.map((k) =>
`${k}=${encodeURIComponent(params[k])}`).join("&");
const signature = crypto.createHmac("sha1",
<secret-key>).update(encodedSortedQuery.toLowerCase()).digest("base64");
const encodedSignature = encodeURIComponent(signature);
const signedUrl =
`<host>?${encodedSortedQuery}&signature=${encodedSignature}`;
```
For the purpose of if someone is having errors and want to check the scenario
in js
GitHub link:
https://github.com/apache/cloudstack/discussions/11146#discussioncomment-13690991
----
This is an automatically sent email for [email protected].
To unsubscribe, please send an email to: [email protected]