Closed CookyNdi closed 3 months ago
you need to login via login_lazer
I attempted to log in via lazer just now it worked, but nothing happened with chat v2.chat.new.
const message = 'hi';
const userId = '16983379';
await lazerLogin();
const result = await v2.chat.new(userId, message);
If I console the result, it is just an empty string.
note : every time i make a request with lazer auth i keep getting a verification email from osu
every time i make a request with lazer auth i keep getting a verification email from osu
cache auth token and reuse it later on, until it expires
If I console the result, it is just an empty string.
is message sended to user?
is message sended to user?
No, no new messages coming into the id i entered
will look tomorrow what is wrong
for now, can you try making a token caching, and after verify latest auth, and then try running request again, maybe it'll fix it
I tried to save the previous token in a file, I also verified it by clicking the link in the email
// chat.ts
const token = readTokenFromFile();
if (!token || token.expires_in < Date.now()) {
await lazerLogin();
}
console.log({ token });
const result = await v2.chat.new(userId, message);
// auth.ts
export const lazerLogin = async () => {
const res = await auth.login_lazer('', '');
saveTokenToFile(res);
console.log('lazer', res);
};
but still getting this error
"error": "A required scope is missing."
i not really understand how auth work in this part
but still getting this error
"error": "A required scope is missing."
Hi! Iirc all auth methods require a scope array. In auth.login_lazer()
it's the last parameter. ["public"]
should do just fine.
In auth.login_lazer() it's the last parameter. ["public"] should do just fine.
it's getting error
i just checked, and it's working
const { auth, v2 } = require('osu-api-extended');
const fs = require('fs');
const lazer_auth = async () => {
const txtPath = 'token2.txt';
if (fs.existsSync(txtPath)) {
const token = fs.readFileSync(txtPath, 'utf8');
auth.set_v2(token);
return
};
const cli = await auth.login_lazer(nickname, password);
console.log(cli);
fs.writeFileSync(txtPath, cli.access_token, 'utf8');
};
async function main() {
try {
await lazer_auth();
const result = await v2.chat.new(2070907, 'hi');
console.log(result);
} catch (error) {
console.log(error);
};
};
main();
thank you so much, i'm just missing auth.set_v2(token);
Hello there, It might just be a simple oversight, but I'm encountering some issues with authentication while attempting to send a chat message.
Here's the code :
And i'm getting this error:
Then i'm tried adding authentication:
And received this response:
note : I encounter no issues when using the function for a beatmap with "public" scope, but when I attempt to add a scope for chat, some problems arise.