mirror of
https://github.com/Pandipipas/scoreko-dev.git
synced 2026-06-06 03:32:06 +00:00
Fix start.gg OAuth endpoints and document required client config
This commit is contained in:
@@ -5,6 +5,23 @@
|
|||||||
"properties": {
|
"properties": {
|
||||||
"exampleProperty": {
|
"exampleProperty": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
|
},
|
||||||
|
"startggClientId": {
|
||||||
|
"type": "string",
|
||||||
|
"default": "",
|
||||||
|
"description": "Client ID de tu OAuth app de start.gg"
|
||||||
|
},
|
||||||
|
"startggClientSecret": {
|
||||||
|
"type": "string",
|
||||||
|
"default": "",
|
||||||
|
"description": "Client Secret de tu OAuth app de start.gg"
|
||||||
|
},
|
||||||
|
"startggOAuthPort": {
|
||||||
|
"type": "integer",
|
||||||
|
"default": 34920,
|
||||||
|
"minimum": 1,
|
||||||
|
"maximum": 65535,
|
||||||
|
"description": "Puerto local para callback OAuth"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"required": [
|
"required": [
|
||||||
|
|||||||
@@ -425,7 +425,7 @@ onBeforeUnmount(() => {
|
|||||||
Integración start.gg
|
Integración start.gg
|
||||||
</div>
|
</div>
|
||||||
<div class="text-caption q-mb-md">
|
<div class="text-caption q-mb-md">
|
||||||
Conecta por OAuth (recomendado) o pega tu token personal para cargar tus torneos creados o donde eres admin.
|
Conecta por OAuth (recomendado) o pega tu token personal para cargar tus torneos creados o donde eres admin. Si aparece "Client authentication failed", revisa que en config uses el Client ID/Secret de un OAuth App de start.gg.
|
||||||
</div>
|
</div>
|
||||||
<div class="row q-col-gutter-sm items-center">
|
<div class="row q-col-gutter-sm items-center">
|
||||||
<div class="col-12">
|
<div class="col-12">
|
||||||
|
|||||||
+13
-11
@@ -4,8 +4,8 @@ import { getData, type CountryRecord } from 'country-list';
|
|||||||
import { nodecg } from './util/nodecg.js';
|
import { nodecg } from './util/nodecg.js';
|
||||||
|
|
||||||
const STARTGG_ENDPOINT = 'https://api.start.gg/gql/alpha';
|
const STARTGG_ENDPOINT = 'https://api.start.gg/gql/alpha';
|
||||||
const STARTGG_OAUTH_AUTHORIZE_ENDPOINT = 'https://start.gg/oauth/authorize';
|
const STARTGG_OAUTH_AUTHORIZE_ENDPOINT = 'https://api.start.gg/oauth/authorize';
|
||||||
const STARTGG_OAUTH_TOKEN_ENDPOINT = 'https://api.start.gg/oauth/token';
|
const STARTGG_OAUTH_TOKEN_ENDPOINT = 'https://api.start.gg/oauth/access_token';
|
||||||
const STARTGG_OAUTH_SCOPES = 'user.identity tournament.manager';
|
const STARTGG_OAUTH_SCOPES = 'user.identity tournament.manager';
|
||||||
const STARTGG_OAUTH_CALLBACK_PATH = '/startgg/callback';
|
const STARTGG_OAUTH_CALLBACK_PATH = '/startgg/callback';
|
||||||
const STARTGG_OAUTH_DEFAULT_PORT = 34920;
|
const STARTGG_OAUTH_DEFAULT_PORT = 34920;
|
||||||
@@ -168,18 +168,20 @@ const exchangeOAuthCodeForToken = async (
|
|||||||
redirectUri: string,
|
redirectUri: string,
|
||||||
oauthConfig: OAuthConfig,
|
oauthConfig: OAuthConfig,
|
||||||
): Promise<string> => {
|
): Promise<string> => {
|
||||||
|
const params = new URLSearchParams({
|
||||||
|
grant_type: 'authorization_code',
|
||||||
|
code,
|
||||||
|
client_id: oauthConfig.clientId,
|
||||||
|
client_secret: oauthConfig.clientSecret,
|
||||||
|
redirect_uri: redirectUri,
|
||||||
|
});
|
||||||
|
|
||||||
const response = await fetch(STARTGG_OAUTH_TOKEN_ENDPOINT, {
|
const response = await fetch(STARTGG_OAUTH_TOKEN_ENDPOINT, {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/x-www-form-urlencoded',
|
||||||
},
|
},
|
||||||
body: JSON.stringify({
|
body: params.toString(),
|
||||||
grant_type: 'authorization_code',
|
|
||||||
code,
|
|
||||||
client_id: oauthConfig.clientId,
|
|
||||||
client_secret: oauthConfig.clientSecret,
|
|
||||||
redirect_uri: redirectUri,
|
|
||||||
}),
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const payload = (await response.json()) as OAuthTokenResponse;
|
const payload = (await response.json()) as OAuthTokenResponse;
|
||||||
@@ -302,7 +304,7 @@ const ensureOAuthCallbackServer = async (oauthConfig: OAuthConfig) => {
|
|||||||
nodecg.listenFor('startgg:createOAuthSession', async (_payload: unknown, ack) => {
|
nodecg.listenFor('startgg:createOAuthSession', async (_payload: unknown, ack) => {
|
||||||
const oauthConfig = getOAuthConfig();
|
const oauthConfig = getOAuthConfig();
|
||||||
if (!oauthConfig) {
|
if (!oauthConfig) {
|
||||||
sendAck(ack, 'OAuth no está configurado en esta instalación (faltan startggClientId/startggClientSecret).');
|
sendAck(ack, 'OAuth no está configurado en esta instalación (faltan startggClientId/startggClientSecret). Usa el Client ID y Client Secret del OAuth app de start.gg.');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Vendored
+12
@@ -8,4 +8,16 @@
|
|||||||
|
|
||||||
export interface Configschema {
|
export interface Configschema {
|
||||||
exampleProperty: string;
|
exampleProperty: string;
|
||||||
|
/**
|
||||||
|
* Client ID de tu OAuth app de start.gg
|
||||||
|
*/
|
||||||
|
startggClientId?: string;
|
||||||
|
/**
|
||||||
|
* Client Secret de tu OAuth app de start.gg
|
||||||
|
*/
|
||||||
|
startggClientSecret?: string;
|
||||||
|
/**
|
||||||
|
* Puerto local para callback OAuth
|
||||||
|
*/
|
||||||
|
startggOAuthPort?: number;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user