Skip to content

Commit

Permalink
feat(Routes): add missing OAuth2 routes (#218)
Browse files Browse the repository at this point in the history
  • Loading branch information
MattIPv4 committed Oct 9, 2021
1 parent 24f658d commit 9dd3446
Show file tree
Hide file tree
Showing 4 changed files with 108 additions and 12 deletions.
30 changes: 27 additions & 3 deletions deno/rest/v8/mod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -569,6 +569,30 @@ export const Routes = {
return `/oauth2/@me` as const;
},

/**
* Route for:
* - GET `/oauth2/authorize`
*/
oauth2Authorization() {
return `/oauth2/authorize` as const;
},

/**
* Route for:
* - POST `/oauth2/token`
*/
oauth2TokenExchange() {
return `/oauth2/token` as const;
},

/**
* Route for:
* - POST `/oauth2/token/revoke`
*/
oauth2TokenRevocation() {
return `/oauth2/token/revoke` as const;
},

/**
* Route for:
* - GET `/applications/{application.id}/commands`
Expand Down Expand Up @@ -728,12 +752,12 @@ export const RouteBases = {
Object.freeze(RouteBases);

export const OAuth2Routes = {
authorizationURL: `https://discord.com/api/v${APIVersion}/oauth2/authorize`,
tokenURL: `https://discord.com/api/v${APIVersion}/oauth2/token`,
authorizationURL: `${RouteBases.api}${Routes.oauth2Authorization()}`,
tokenURL: `${RouteBases.api}${Routes.oauth2TokenExchange()}`,
/**
* See https://tools.ietf.org/html/rfc7009
*/
tokenRevocationURL: `https://discord.com/api/v${APIVersion}/oauth2/token/revoke`,
tokenRevocationURL: `${RouteBases.api}${Routes.oauth2TokenRevocation()}`,
} as const;

// Freeze OAuth2 route object
Expand Down
30 changes: 27 additions & 3 deletions deno/rest/v9/mod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -637,6 +637,30 @@ export const Routes = {
return `/oauth2/@me` as const;
},

/**
* Route for:
* - GET `/oauth2/authorize`
*/
oauth2Authorization() {
return `/oauth2/authorize` as const;
},

/**
* Route for:
* - POST `/oauth2/token`
*/
oauth2TokenExchange() {
return `/oauth2/token` as const;
},

/**
* Route for:
* - POST `/oauth2/token/revoke`
*/
oauth2TokenRevocation() {
return `/oauth2/token/revoke` as const;
},

/**
* Route for:
* - GET `/applications/{application.id}/commands`
Expand Down Expand Up @@ -796,12 +820,12 @@ export const RouteBases = {
Object.freeze(RouteBases);

export const OAuth2Routes = {
authorizationURL: `https://discord.com/api/v${APIVersion}/oauth2/authorize`,
tokenURL: `https://discord.com/api/v${APIVersion}/oauth2/token`,
authorizationURL: `${RouteBases.api}${Routes.oauth2Authorization()}`,
tokenURL: `${RouteBases.api}${Routes.oauth2TokenExchange()}`,
/**
* See https://tools.ietf.org/html/rfc7009
*/
tokenRevocationURL: `https://discord.com/api/v${APIVersion}/oauth2/token/revoke`,
tokenRevocationURL: `${RouteBases.api}${Routes.oauth2TokenRevocation()}`,
} as const;

// Freeze OAuth2 route object
Expand Down
30 changes: 27 additions & 3 deletions rest/v8/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -569,6 +569,30 @@ export const Routes = {
return `/oauth2/@me` as const;
},

/**
* Route for:
* - GET `/oauth2/authorize`
*/
oauth2Authorization() {
return `/oauth2/authorize` as const;
},

/**
* Route for:
* - POST `/oauth2/token`
*/
oauth2TokenExchange() {
return `/oauth2/token` as const;
},

/**
* Route for:
* - POST `/oauth2/token/revoke`
*/
oauth2TokenRevocation() {
return `/oauth2/token/revoke` as const;
},

/**
* Route for:
* - GET `/applications/{application.id}/commands`
Expand Down Expand Up @@ -728,12 +752,12 @@ export const RouteBases = {
Object.freeze(RouteBases);

export const OAuth2Routes = {
authorizationURL: `https://discord.com/api/v${APIVersion}/oauth2/authorize`,
tokenURL: `https://discord.com/api/v${APIVersion}/oauth2/token`,
authorizationURL: `${RouteBases.api}${Routes.oauth2Authorization()}`,
tokenURL: `${RouteBases.api}${Routes.oauth2TokenExchange()}`,
/**
* See https://tools.ietf.org/html/rfc7009
*/
tokenRevocationURL: `https://discord.com/api/v${APIVersion}/oauth2/token/revoke`,
tokenRevocationURL: `${RouteBases.api}${Routes.oauth2TokenRevocation()}`,
} as const;

// Freeze OAuth2 route object
Expand Down
30 changes: 27 additions & 3 deletions rest/v9/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -637,6 +637,30 @@ export const Routes = {
return `/oauth2/@me` as const;
},

/**
* Route for:
* - GET `/oauth2/authorize`
*/
oauth2Authorization() {
return `/oauth2/authorize` as const;
},

/**
* Route for:
* - POST `/oauth2/token`
*/
oauth2TokenExchange() {
return `/oauth2/token` as const;
},

/**
* Route for:
* - POST `/oauth2/token/revoke`
*/
oauth2TokenRevocation() {
return `/oauth2/token/revoke` as const;
},

/**
* Route for:
* - GET `/applications/{application.id}/commands`
Expand Down Expand Up @@ -796,12 +820,12 @@ export const RouteBases = {
Object.freeze(RouteBases);

export const OAuth2Routes = {
authorizationURL: `https://discord.com/api/v${APIVersion}/oauth2/authorize`,
tokenURL: `https://discord.com/api/v${APIVersion}/oauth2/token`,
authorizationURL: `${RouteBases.api}${Routes.oauth2Authorization()}`,
tokenURL: `${RouteBases.api}${Routes.oauth2TokenExchange()}`,
/**
* See https://tools.ietf.org/html/rfc7009
*/
tokenRevocationURL: `https://discord.com/api/v${APIVersion}/oauth2/token/revoke`,
tokenRevocationURL: `${RouteBases.api}${Routes.oauth2TokenRevocation()}`,
} as const;

// Freeze OAuth2 route object
Expand Down

0 comments on commit 9dd3446

Please sign in to comment.