Skip to content

Commit 890cbc6

Browse files
committed
fix: fixed the registerdevice and loginwithtoken that wasnt using the correct url
1 parent a6bf1ed commit 890cbc6

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

examples/login.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { getSmartschoolLoginUrl, GetOIDCAccessTokens, OIDCRefresh, isValidInstan
55
import { crypto } from '@noble/hashes/crypto';
66
import {generateRandomCode} from '../src/util/Verifier';
77
import { url } from 'inspector';
8+
import { LoginWithToken } from '../src';
89

910
const TOKEN_ENDPOINT_PATH = "/OAuth/mobile/token";
1011
function base64UrlEncode(buffer: ArrayBuffer): string {
@@ -66,7 +67,7 @@ let auth: { access_token: string; refresh_token: string; } = { access_token: '',
6667
try {
6768
console.log(`[DEBUG] Token endpoint: ${baseURL}`);
6869
console.log(`[DEBUG] Refreshing access token with refresh token: ${auth.refresh_token}`);
69-
const newTokens = await OIDCRefresh(baseURL, auth.refresh_token);
70+
const newTokens = await LoginWithToken(baseURL + "/OAuth/mobile/token", auth.refresh_token, "android", "testpapillon", crypto.randomUUID());
7071
console.log(`\x1b[32m✓\x1b[0m Token refresh successful!`);
7172
console.log(newTokens);
7273
} catch (error) {

src/routes/User.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ import { Kind } from "../util/Constants";
77
import { BaseResponse } from "../types/RequestHandler";
88
import { KidData, studentIncluded, UserAttributes } from "../types/User";
99
import { getMultipleRelations } from "../util/Relations";
10+
import { log } from "console";
11+
import { extractBaseUrl } from "../util/URL";
1012

1113

1214
export const RegisterDevice = async (
@@ -17,7 +19,8 @@ export const RegisterDevice = async (
1719
deviceName: string,
1820
deviceId: string
1921
): Promise<SmartSchool> => {
20-
const manager = new RestManager(url);
22+
const [base] = extractBaseUrl(url);
23+
const manager = new RestManager(base);
2124

2225
const headers = {
2326
Authorization: `Bearer ${accessToken}`

0 commit comments

Comments
 (0)