Back

Telegram

  • 0
  • Web
mimikatz5562
29 Jun, 2024, 19:27

I created a function to handle custom tokens. If I do the execution from the uppwrite platform everything works fine. if I make a request from postman or from the application client nothing gets anywhere. Or it generates errors.

Am I doing the function request correctly? Nothing comes through when I call this function.

export async function authenticateWithTelegram(webAppUser, username) { try { const response = await fetch('http://667eca820456a6e6a0fe.appwrite.global/', { method: 'POST', headers: { 'Content-Type': 'application/json', 'X-Appwrite-Key': apiJWT }, body: JSON.stringify({ telegramUserId: webAppUser.toString(), telegramUsername: username, }), }); const data = await response.json(); console.log('Server response:', data);

TypeScript
        const session = await account.createSession(userId, secret);
        console.log('Session created:', session);

        return session;
    } catch (error) {
        console.error('Authentication error:', error);
        throw error;
}

}

TL;DR
Issue: Function to handle custom tokens works from uppwrite platform but not from Postman or application client. Solution: The fetch URL in the code block might be incorrect. Double-check the URL to ensure it is accessible from all sources.
Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more