Connect with rNet
Connect with rNet signs users in and lets your app spend their credits. It uses OAuth 2.0 with the authorization code flow and PKCE. The SDKs handle the protocol details for you.
The flow
User clicks Connect with rNet
Your server creates a PKCE verifier and challenge plus a random state, stores the verifier and state in the user's session, and redirects to rNet.
User signs in and allows your app
rNet shows your app name and what it can do: see the user's name and email address, and use their rNet credits for AI requests they make in your app.
rNet redirects back with a code
The user returns to your redirect URI with code and state. Check that state matches what you stored.
Your server exchanges the code
Your server sends the code and verifier to rNet and receives an access token and a refresh token for this user.
Start sign-in
// Create a PKCE pair and keep the verifier in the user's server-side session
const { verifier, challenge } = auth.generatePKCE();
const state = crypto.randomUUID();
req.session.rnet = { verifier, state };
// Send the user to rNet to sign in and approve your app
res.redirect(auth.getAuthorizationUrl(challenge, state));Handle the callback
// GET /callback?code=...&state=...
const { verifier, state } = req.session.rnet;
if (req.query.state !== state) return res.status(400).send('Invalid state');
const tokens = await auth.exchangeCodeForToken(req.query.code, verifier);
req.session.rnet = {
accessToken: tokens.access_token,
refreshToken: tokens.refresh_token,
};Get the user's profile
const user = await auth.getUserInfo(accessToken); console.log(user.email, user.name);
| Field | Description |
|---|---|
sub | Stable user identifier. |
email | The user's email address. |
email_verified | Whether the email is verified. |
name | The user's name. |
preferred_username | Username. |
user_id | rNet user ID. |
role | USER or DEVELOPER. |
status | Account status. |
Scopes are openid profile email; the SDKs request them for you. The fields above may vary by account.
Button guidelines
- Label the button Connect with rNet. Write rNet with a lowercase r and capital N.
- Show the rNet icon on the left. You can use
https://www.rnetai.org/favicon.svg. - Use a neutral style that fits your app, or rNet green (
#059345) with white text. - Keep it at least 40px tall and as easy to find as your other sign-in options.
<a href="/auth/rnet" class="rnet-button">
<img src="https://www.rnetai.org/favicon.svg" alt="" width="20" height="20" />
Connect with rNet
</a>
<style>
.rnet-button {
display: inline-flex; align-items: center; gap: 8px;
height: 40px; padding: 0 16px; border-radius: 8px;
border: 1px solid #e5e5e5; background: #fff; color: #171717;
font: 500 14px/1 system-ui, sans-serif; text-decoration: none;
}
.rnet-button:hover { background: #f4f4f4; }
</style>Raw endpoints
Not using an SDK? See the Authentication API for the authorize, token and userinfo endpoints.