How to OAuth
Depending on your usage, you can implement this with pop-up window or redirection
Popup window method
Add a message event listener like the following
Redirect method
Set location.href
If the oauth success, the token will be included as the search param to the redirect_url provided.
You can get the redirect token with the following code:
After getting the token, you can request the user information with the following API
Fetch with token
Headers
Content-Type
application/json
oauth-token
{jwt_token_you_get}
Body(JSON
id
string
id of the user
linkedAddress
string
linked ETH address
token
Object
Type as below
Response
Telegram mini app oauth
Use the update account API to update your "tgResultCallbackURL", "tgBotID", "tgBotMiniAppURL"
Add the following code to your link/login well3 button callback
Receive the result callback in your backend. The request will be a GET request, with a jwt attached to the API query. Nodejs example code:
Our telegram bot will have a button to redirect the user back to your telegram mini app with the tgBotMiniAppURL you provided, so it is important to fill in the URL.
When the user go back to your bot, fetch the access token stored in your server to get the Well user info.
Last updated