Skip to content

Commit

Permalink
feat: add a method to (re)authorize a client
Browse files Browse the repository at this point in the history
This can be used to switch out the authorized user to allow for
client object re-use.
  • Loading branch information
thislooksfun committed Apr 9, 2021
1 parent 724c22b commit d86550d
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,21 @@ export default class Client {
this.subreddits = new SubredditControls(this);
}

/**
* (re)authorize this client.
*
* This can be used to
*
* @param auth The new authorization.
*
* @returns A promise that resolves when the reauthorization is complete.
*/
async reAuth(auth: Auth): Promise<void> {
this.auth = auth;
this.token = null;
await this.updateAccessToken();
}

/**
* Perform a GET request to the reddit api.
*
Expand Down

0 comments on commit d86550d

Please sign in to comment.