Skip to content

Commit 7bcd50a

Browse files
committed
auth: Make OAuth2User.generateAuthURL async
1 parent 0d12a20 commit 7bcd50a

6 files changed

+6
-6
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ const client = new Client(authClient);
136136
### Generating an Authentication URL
137137

138138
```typescript
139-
const authUrl = authClient.generateAuthURL({
139+
const authUrl = await authClient.generateAuthURL({
140140
code_challenge_method: "s256",
141141
});
142142
```

examples/oauth2-callback.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ app.get("/callback", async function (req, res) {
3232
});
3333

3434
app.get("/login", async function (req, res) {
35-
const authUrl = authClient.generateAuthURL({
35+
const authUrl = await authClient.generateAuthURL({
3636
state: STATE,
3737
code_challenge_method: "s256",
3838
});

examples/oauth2-callback_pkce_plain.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ app.get("/callback", async function (req, res) {
3232
});
3333

3434
app.get("/login", async function (req, res) {
35-
const authUrl = authClient.generateAuthURL({
35+
const authUrl = await authClient.generateAuthURL({
3636
state: STATE,
3737
code_challenge_method: "plain",
3838
code_challenge: "test",

examples/oauth2-callback_pkce_s256.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ app.get("/callback", async function (req, res) {
3232
});
3333

3434
app.get("/login", async function (req, res) {
35-
const authUrl = authClient.generateAuthURL({
35+
const authUrl = await authClient.generateAuthURL({
3636
state: STATE,
3737
code_challenge_method: "s256",
3838
});

examples/oauth2-public-callback_pkce_s256.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ app.get("/callback", async function (req, res) {
3131
});
3232

3333
app.get("/login", async function (req, res) {
34-
const authUrl = authClient.generateAuthURL({
34+
const authUrl = await authClient.generateAuthURL({
3535
state: STATE,
3636
code_challenge_method: "s256",
3737
});

src/OAuth2User.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ export class OAuth2User implements AuthClient {
242242
});
243243
}
244244

245-
generateAuthURL(options: GenerateAuthUrlOptions): string {
245+
async generateAuthURL(options: GenerateAuthUrlOptions): Promise<string> {
246246
const { client_id, callback, scopes } = this.#options;
247247
if (!callback) throw new Error("callback required");
248248
if (!scopes) throw new Error("scopes required");

0 commit comments

Comments
 (0)