> ## Documentation Index
> Fetch the complete documentation index at: https://docs.didit.me/llms.txt
> Use this file to discover all available pages before exploring further.

# प्रमाणीकरण क्विकस्टार्ट: 10 मिनट में पहला साइन-इन

> सैंडबॉक्स एप्लिकेशन में Didit Authentication चालू करें, होस्टेड पेज से किसी व्यक्ति को साइन-इन कराएँ और सर्वर पर उसके access token को सत्यापित करें।

यह क्विकस्टार्ट लगभग 10 मिनट में Didit Authentication को शुरू से अंत तक काम करने की सुविधा देता है।
आप एक सैंडबॉक्स एप्लिकेशन में कॉलबैक पंजीकृत करते हैं, एक साइन-इन विधि चालू करते हैं, होस्टेड साइन-इन पेज के माध्यम से किसी व्यक्ति को साइन इन कराते हैं, अपने सर्वर पर उसके एक्सेस टोकन को सत्यापित करते हैं, और कंसोल में साइन-इन देखते हैं।

## पूर्वापेक्षाएँ

* एक Didit खाता, जिसमें एक सैंडबॉक्स एप्लिकेशन हो। खाता बनाना निःशुल्क है, और हर सैंडबॉक्स एप्लिकेशन में प्रमाणीकरण चालू होता है।
* Node.js 20 या बाद का संस्करण, और एक वेब ऐप जिसे आप `http://localhost:3000` पर चला सकें।

## चरण

**1. अपना सैंडबॉक्स एप्लिकेशन खोलें**

[Business Console](https://business.didit.me) में, एप्लिकेशन स्विचर से अपना **Sandbox** एप्लिकेशन चुनें, फिर **Authentication** खोलें।

एक Sandbox एप्लिकेशन `http://localhost` कॉलबैक और सोशल साइन-इन के लिए Didit के टेस्ट क्रेडेंशियल स्वीकार करता है, और उस पर कभी बिलिंग नहीं होती।
लाइव एप्लिकेशन के लिए Authentication **Products** पेज से चालू करें: देखें [अपने एप्लिकेशन को तैयार करें](https://docs.didit.me/hi/authentication/overview.md#अपना-एप्लिकेशन-तैयार-करें)।

**2. अपना कॉलबैक और ओरिजिन रजिस्टर करें**

**Authentication > Security and sessions > Redirect URLs and allowed origins** खोलें और ये जोड़ें:

| विवरण | मान |
| - | - |
| Redirect URL | `http://localhost:3000/auth/callback` |
| Allowed origin | `http://localhost:3000` |

Didit किसी व्यक्ति को केवल उसी redirect URL पर भेजता है जिसे आपने रजिस्टर किया है, अक्षर-दर-अक्षर मिलान के साथ।
Allowed origin ब्राउज़र को आपके एप्लिकेशन के Didit ओरिजिन के साथ कोड का आदान-प्रदान करने देता है।

![Didit Business Console में Redirect URLs and allowed origins कार्ड, allowlist और blocklist तथा sign-in URL के बगल में](https://mintcdn.com/didit-0f962782/RpqZjIB1GnUPdMTN/images/authentication/console-redirect-urls.png?fit=max\&auto=format\&n=RpqZjIB1GnUPdMTN\&q=85\&s=8bf9cdacf97580097f4e8c6bd242af6f)

Redirect URLs और allowed origins, Authentication > Security and sessions के अंतर्गत।

**3. एक साइन-इन विधि चालू करें**

**Authentication > Sign-in methods** खोलें और **Email code** चालू करें।
नया एप्लिकेशन सभी विधियाँ बंद करके शुरू होता है, और होस्टेड पेज केवल वही विधियाँ दिखाता है जो आपने चालू की हैं।

चाहें तो **Passkeys** भी जोड़ सकते हैं, या **Didit test credentials** के साथ कोई सोशल साइन-इन विधि, जो बिना अपने ऐप के Sandbox में काम करती है।
हर विधि का वर्णन [साइन-इन विधियाँ](https://docs.didit.me/hi/authentication/sign-in-methods.md) में है।

![Didit Business Console में Sign-in methods पेज, होस्टेड साइन-इन पेज कार्ड, पासवर्डरहित और पासवर्ड विधियों और होस्टेड पेज के लाइव प्रीव्यू के साथ](https://mintcdn.com/didit-0f962782/RpqZjIB1GnUPdMTN/images/authentication/console-sign-in-methods.png?fit=max\&auto=format\&n=RpqZjIB1GnUPdMTN\&q=85\&s=4f71ad0125f22dd8184ad837854ec8db)

Authentication > Sign-in methods, होस्टेड पेज के लाइव प्रीव्यू के साथ।

**4. अपनी publishable key कॉपी करें**

**Authentication > Developers** खोलें और **Publishable key** कॉपी करें।
Sandbox एप्लिकेशन में यह `pk_test_` से शुरू होती है।

Publishable key सार्वजनिक है और आपके एप्लिकेशन के Didit साइन-इन ओरिजिन की पहचान करती है।
**Secret key** को कभी ब्राउज़र या मोबाइल कोड में न डालें।

**5. SDK इंस्टॉल करें और साइन इन करें**

```bash theme={null}
npm install @didit-protocol/auth
```

```ts auth.ts theme={null}
import { createDiditAuth } from "@didit-protocol/auth";

export const auth = createDiditAuth({
  publishableKey: "pk_test_...",
  redirectUri: "http://localhost:3000/auth/callback",
});

// Your sign-in button
export async function onSignInClick() {
  await auth.signIn({ returnTo: "/dashboard" });
}

// Run once on http://localhost:3000/auth/callback
export async function onCallbackPage() {
  const { session, returnTo } = await auth.handleRedirectCallback();
  console.log(session.email, session.vendorData);
  window.location.replace(returnTo ?? "/");
}
```

अपना बटन क्लिक करें: होस्टेड पेज एक ईमेल पता माँगता है और छह अंकों का कोड भेजता है।
कोड डालें, और Didit आपको आपके कॉलबैक पर वापस भेज देता है, जो वन-टाइम कोड को सत्र के टोकन में बदलता है।
जिस पते का कोई खाता नहीं है, उससे पहली बार साइन इन करने पर खाता बन जाता है, क्योंकि डिफ़ॉल्ट साइन-अप नीति किसी को भी साइन अप करने देती है।

![फ़ोन पर होस्टेड साइन-इन पेज, जिसमें पासकी बटन और ईमेल तथा पासवर्ड फ़ील्ड हैं](https://mintcdn.com/didit-0f962782/RpqZjIB1GnUPdMTN/images/authentication/hosted-sign-in-phone.png?fit=max\&auto=format\&n=RpqZjIB1GnUPdMTN\&q=85\&s=842077ff63a6dcffc50b0f0542ab07e4)

एक फ़ोन पर होस्टेड साइन-इन पेज। इसमें केवल वही विधियाँ दिखती हैं जो आपने चालू की हैं।

**6. सर्वर पर टोकन सत्यापित करें**

`auth.getToken()` से मिला एक्सेस टोकन `Authorization` हेडर में अपने बैकएंड को भेजें, और हर सुरक्षित अनुरोध पर उसे वहीं सत्यापित करें:

```ts server.ts theme={null}
import { verifyToken } from "@didit-protocol/auth/server";

export async function authenticate(request: Request) {
  const header = request.headers.get("authorization") ?? "";
  const token = header.startsWith("Bearer ") ? header.slice(7) : "";
  try {
    const claims = await verifyToken(token, { publishableKey: process.env.DIDIT_PUBLISHABLE_KEY });
    return { personId: claims.sub, vendorData: claims.vendor_data };
  } catch {
    return null;
  }
}
```

`verifyToken` आपके जारीकर्ता की प्रकाशित कुंजियों के विरुद्ध ES256 हस्ताक्षर, issuer और समाप्ति की जाँच करता है।
एक्सेस टोकन अधिकतम 5 मिनट तक चलते हैं, और `auth.getToken()` उन्हें आपके लिए रीफ़्रेश करता है।
अन्य भाषाओं में उसी टोकन को [server SDKs](https://docs.didit.me/hi/integration/server-sdks/overview.md) से, या किसी भी JWT लाइब्रेरी से सत्यापित किया जा सकता है, जैसा [tokens और JWKS](https://docs.didit.me/hi/authentication/tokens-and-jwks.md#अपने-सर्वर-पर-टोकन-सत्यापित-करें) में दिखाया गया है।

**7. कंसोल में साइन-इन देखें**

**Authentication > Sign-ins** खोलें।
आपका साइन-इन अपने परिणाम, विधि, डिवाइस, स्थान और जोखिम के साथ सूचीबद्ध होता है, उन उदाहरण साइन-इन के बगल में जिनसे हर सैंडबॉक्स शुरू होता है।
व्यक्ति **Users** के अंतर्गत दिखाई देता है।

![Didit Business Console में Sign-ins पेज, जिसमें साइन-इन प्रयास उनकी स्थिति, व्यक्ति, विधि, डिवाइस, स्थान, जोखिम और समय के साथ सूचीबद्ध हैं](https://mintcdn.com/didit-0f962782/RpqZjIB1GnUPdMTN/images/authentication/console-sign-ins.png?fit=max\&auto=format\&n=RpqZjIB1GnUPdMTN\&q=85\&s=3c79b4e120c911b732d738e52d1687c8)

Authentication > Sign-ins: हर प्रयास, स्थिति, विधि और जोखिम के फ़िल्टर के साथ।

अपने सर्वर पर साइन-इन गतिविधि प्राप्त करने के लिए, किसी [webhook गंतव्य](https://docs.didit.me/hi/integration/webhooks.md) को `auth.signup` और `auth.login` की सदस्यता दें। देखें [इवेंट और webhooks](https://docs.didit.me/hi/authentication/events-and-webhooks.md)।

## लाइव होने से पहले

1. **Products** पेज पर अपने Live एप्लिकेशन के लिए Authentication चालू करें।
2. वहीं अपने प्रोडक्शन `https://` रीडायरेक्ट URL और ऑरिजिन पंजीकृत करें: Live एप्लिकेशन केवल `https://` स्वीकार करता है।
3. सोशल साइन-इन के लिए Didit के टेस्ट क्रेडेंशियल को अपने एप्लिकेशन के क्लाइंट ID और सीक्रेट से बदलें।
4. Live पब्लिशेबल कुंजी (`pk_live_`) को अपने प्रोडक्शन कॉन्फ़िगरेशन में कॉपी करें।
5. [गो-लाइव चेकलिस्ट](https://docs.didit.me/hi/authentication/integration-guide.md#गो-लाइव-चेकलिस्ट) के हर चरण से गुजरें।

## अगले चरण

> [card] [इंटीग्रेशन गाइड](https://docs.didit.me/hi/authentication/integration-guide.md)
>
> होस्टेड या आपकी अपनी स्क्रीन, टोकन स्टोरेज, सत्र, स्टेप-अप और समस्या निवारण।

> [card] [React और Next.js](https://docs.didit.me/hi/authentication/quickstarts/nextjs.md)
>
> कंपोनेंट, हुक, HttpOnly कुकीज़ और सर्वर पर `auth()`।

> [card] [iOS, Android, React Native और Flutter](https://docs.didit.me/hi/authentication/quickstarts/ios.md)
>
> सिस्टम ब्राउज़र के साथ नेटिव साइन-इन, पासकी और सुरक्षित स्टोरेज।

> [card] [बॉट सुरक्षा](https://docs.didit.me/hi/authentication/bot-protection.md)
>
> बॉट और अकाउंट टेकओवर को रोकने वाली नीतियाँ चालू करें।


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.