Some APIs require authentication using a query parameter in the URL. For example, the Clubhouse API has examples that look like this:
curl -X GET \
-H "Content-Type: application/json" \
-L "https://api.clubhouse.io/api/v3/member?token=$CLUBHOUSE_API_TOKEN"
To resolve this issue, auth.ts should define and export a class that can handle automatically attaching a token to the query parameters in the URL. For example:
export class QueryParamHandler implements ifm.IRequestHandler {
param: string
token: string;
constructor(token: string, param="token") {
this.token = token;
this.param = param;
}
prepareRequest(options:any): void {
// not sure where to find request URL, so this is pseudocode...
if (this.url.contains("?")) {
this.url += `&${this.param}=${this.token}`;
} else {
this.url += `?${this.param}=${this.token}`;
}
}
}