Skip to content
This repository was archived by the owner on May 3, 2022. It is now read-only.
This repository was archived by the owner on May 3, 2022. It is now read-only.

Should be able to authenticate using a URL query parameter #19

Description

@singingwolfboy

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}`;
        }
    }
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions