OAuth और 'Google साइन इन' के साथ व्यवस्थित लिंक करना

खास जानकारी

OAuth पर आधारित 'Google साइन इन' को बेहतर तरीके से लिंक करने की सुविधा में, OAuth लिंकिंग के सबसे ऊपर Google साइन इन की सुविधा जोड़ी जाती है. इससे Google उपयोगकर्ताओं को बिना किसी रुकावट के अनुभव मिलता है. साथ ही, इससे खाता भी बनाया जा सकता है, जिससे उपयोगकर्ता अपने Google खाते का इस्तेमाल करके आपकी सेवा पर एक नया खाता बना सकते हैं.

OAuth और Google साइन इन के साथ खाता जोड़ने के लिए, यह सामान्य तरीका अपनाएं:

  1. सबसे पहले, उपयोगकर्ता से अपनी Google प्रोफ़ाइल ऐक्सेस करने की सहमति दें.
  2. यह देखने के लिए कि उपयोगकर्ता खाता मौजूद है या नहीं, उनकी प्रोफ़ाइल में दी गई जानकारी का इस्तेमाल करें.
  3. मौजूदा उपयोगकर्ताओं के लिए, खाते लिंक करें.
  4. अगर आपको पुष्टि करने वाले सिस्टम में, Google उपयोगकर्ता का कोई मिलान नहीं मिल रहा है, तो Google से मिले आईडी टोकन की पुष्टि करें. फिर आप आईडी टोकन में मौजूद प्रोफ़ाइल की जानकारी के आधार पर उपयोगकर्ता बना सकते हैं.
यह डायग्राम, उपयोगकर्ता को अपने Google खाते को लिंक करने के चरण दिखाता है. इसके लिए, खाता जोड़ने के व्यवस्थित फ़्लो का इस्तेमाल किया जाता है. पहले स्क्रीनशॉट में बताया गया है कि कोई उपयोगकर्ता, लिंक करने के लिए आपके ऐप्लिकेशन को कैसे चुन सकता है. दूसरे स्क्रीनशॉट से उपयोगकर्ता को यह पुष्टि करने में मदद मिलती है कि आपकी सेवा पर कोई मौजूदा खाता है या नहीं. तीसरा स्क्रीनशॉट, उपयोगकर्ता को वह Google खाता चुनने की सुविधा देता है जिससे उसे लिंक करना है. चौथे स्क्रीनशॉट में, Google खाते को आपके ऐप्लिकेशन से जोड़ने की पुष्टि दिखाई गई है. पांचवां स्क्रीनशॉट, Google app में लिंक किए गए उपयोगकर्ता खाते को दिखाता है.

पहली इमेज. व्यवस्थित लिंकिंग के साथ उपयोगकर्ता के फ़ोन पर खाता लिंक करना

व्यवस्थित तरीके से लिंक करने से जुड़ी ज़रूरी शर्तें

  • सामान्य वेब OAuth लिंकिंग फ़्लो लागू करें. आपकी सेवा में, OAuth 2.0 का पालन करने वाली अनुमति और टोकन एक्सचेंज एंडपॉइंट काम करने चाहिए.
  • आपके टोकन एक्सचेंज एंडपॉइंट को, JSON वेब टोकन (JWT) दावों के साथ काम करना चाहिए. साथ ही, check, create, और get इंटेंट को लागू करना चाहिए.

अपना OAuth सर्वर लागू करें

आपके टोकन एक्सचेंज एंडपॉइंट को check, create, और get इंटेंट के साथ काम करना चाहिए. नीचे, खाता जोड़ने के फ़्लो से जुड़े चरण दिखाए गए हैं. साथ ही, यह भी बताता है कि अलग-अलग इंटेंट को कब कॉल किया जाता है:

  1. क्या उपयोगकर्ता के पास आपके प्रमाणीकरण सिस्टम में खाता है? (उपयोगकर्ता 'हां' या 'नहीं' चुनकर तय करता है)
    1. हां : क्या उपयोगकर्ता आपके प्लैटफ़ॉर्म में साइन इन करने के लिए, अपने Google खाते से जुड़े ईमेल पते का इस्तेमाल करता है? (उपयोगकर्ता 'हां' या 'नहीं' चुनकर तय करता है)
      1. हां : क्या उपयोगकर्ता के पास आपके पुष्टि करने वाले सिस्टम में कोई मिलता-जुलता खाता है? (check intent को पुष्टि करने के लिए कॉल किया जाता है)
        1. हां : get intent को कॉल किया जाता है. अगर इंटेंट वापस मिल जाता है, तो खाता जोड़ दिया जाता है.
        2. NO : नया खाता बनाएं? (उपयोगकर्ता 'हां' या 'नहीं' चुनकर तय करता है)
          1. हां : create intent को कॉल किया जाता है. अगर इंटेंट बनाया जाता है, तो खाता लिंक हो जाता है.
          2. नहीं : वेब OAuth फ़्लो ट्रिगर हो जाता है, उपयोगकर्ता को उनके ब्राउज़र पर भेज दिया जाता है और उपयोगकर्ता को किसी दूसरे ईमेल से लिंक करने का विकल्प दिया जाता है.
      2. नहीं : वेब OAuth फ़्लो ट्रिगर हो जाता है, उपयोगकर्ता को उनके ब्राउज़र पर भेज दिया जाता है और उपयोगकर्ता को किसी दूसरे ईमेल से लिंक करने का विकल्प दिया जाता है.
    2. नहीं : क्या उपयोगकर्ता के पास आपके पुष्टि करने वाले सिस्टम में कोई मिलता-जुलता खाता है? (check intent को पुष्टि करने के लिए कॉल किया जाता है)
      1. हां : get intent को कॉल किया जाता है. अगर इंटेंट वापस मिल जाता है, तो खाता जोड़ दिया जाता है.
      2. नहीं : create intent को कॉल किया जाता है और अगर खाता बनाने की प्रोसेस पूरी हो जाती है, तो खाता जोड़ दिया जाता है.

Check for an existing user account (check intent)

After the user gives consent to access their Google profile, Google sends a request that contains a signed assertion of the Google user's identity. The assertion contains information that includes the user's Google Account ID, name, and email address. The token exchange endpoint configured for your project handles that request.

If the corresponding Google account is already present in your authentication system, your token exchange endpoint responds with account_found=true. If the Google account doesn't match an existing user, your token exchange endpoint returns an HTTP 404 Not Found error with account_found=false.

The request has the following form:

POST /token HTTP/1.1
Host: oauth2.example.com
Content-Type: application/x-www-form-urlencoded

grant_type=urn:ietf:params:oauth:grant-type:jwt-bearer&intent=check&assertion=JWT&scope=SCOPES&client_id=GOOGLE_CLIENT_ID&client_secret=GOOGLE_CLIENT_SECRET

Your token exchange endpoint must be able to handle the following parameters:

Token endpoint parameters
intent For these requests, the value of this parameter is check.
grant_type The type of token being exchanged. For these requests, this parameter has the value urn:ietf:params:oauth:grant-type:jwt-bearer.
assertion A JSON Web Token (JWT) that provides a signed assertion of the Google user's identity. The JWT contains information that includes the user's Google Account ID, name, and email address.
client_id The client ID you assigned to Google.
client_secret The client secret you assigned to Google.

To respond to the check intent requests, your token exchange endpoint must perform the following steps:

  • Validate and decode the JWT assertion.
  • Check if the Google account is already present in your authentication system.
मान्य करें और JWT अभिकथन को डिकोड करें

आप अपनी भाषा के लिए JWT- डिकोडिंग लाइब्रेरी का उपयोग करके JWT दावे को मान्य और डिकोड कर सकते हैं । टोकन के हस्ताक्षर को सत्यापित करने के लिए, JWK या PEM प्रारूपों में उपलब्ध Google की सार्वजनिक कुंजियों का उपयोग करें।

जब डिकोड किया जाता है, तो JWT अभिकथन निम्नलिखित उदाहरण की तरह दिखता है:

{
  "sub": "1234567890",      // The unique ID of the user's Google Account
  "iss": "https://accounts.google.com",        // The assertion's issuer
  "aud": "123-abc.apps.googleusercontent.com", // Your server's client ID
  "iat": 233366400,         // Unix timestamp of the assertion's creation time
  "exp": 233370000,         // Unix timestamp of the assertion's expiration time
  "name": "Jan Jansen",
  "given_name": "Jan",
  "family_name": "Jansen",
  "email": "jan@gmail.com", // If present, the user's email address
  "email_verified": true,   // true, if Google has verified the email address
  "hd": "example.com",      // If present, the host domain of the user's GSuite email address
                            // If present, a URL to user's profile picture
  "picture": "https://lh3.googleusercontent.com/a-/AOh14GjlTnZKHAeb94A-FmEbwZv7uJD986VOF1mJGb2YYQ",
  "locale": "en_US"         // User's locale, from browser or phone settings
}

टोकन के हस्ताक्षर की पुष्टि करने के अलावा, पुष्टि करें कि दावे का जारीकर्ता ( iss फ़ील्ड) https://accounts.google.com , कि ऑडियंस ( aud फ़ील्ड) आपका असाइन किया गया क्लाइंट ID है, और टोकन की समय सीमा समाप्त नहीं हुई है ( exp मैदान)।

email , email_verified और hd फ़ील्ड का उपयोग करके आप यह निर्धारित कर सकते हैं कि Google होस्ट ईमेल पते के लिए आधिकारिक है या नहीं। उन मामलों में जहां Google आधिकारिक है, उपयोगकर्ता को वर्तमान में वैध खाता स्वामी के रूप में जाना जाता है और आप पासवर्ड या अन्य चुनौतियों के तरीकों को छोड़ सकते हैं। अन्यथा, इन विधियों का उपयोग लिंक करने से पहले खाते को सत्यापित करने के लिए किया जा सकता है।

ऐसे मामले जहां Google आधिकारिक है:

  • email में @gmail.com प्रत्यय है, यह एक जीमेल खाता है।
  • email_verified सत्य है और hd सेट है, यह एक G Suite खाता है।

उपयोगकर्ता जीमेल या जी सूट का उपयोग किए बिना Google खातों के लिए पंजीकरण कर सकते हैं। जब email @gmail.com प्रत्यय नहीं होता है और hd अनुपस्थित होता है तो Google आधिकारिक नहीं होता है और उपयोगकर्ता को सत्यापित करने के लिए पासवर्ड या अन्य चुनौती विधियों की सिफारिश की जाती है। email_verfied भी सही हो सकता है क्योंकि Google ने उपयोगकर्ता को शुरू में सत्यापित किया था जब Google खाता बनाया गया था, हालांकि तृतीय पक्ष ईमेल खाते का स्वामित्व परिवर्तित होने के बाद हो सकता है।

Check if the Google account is already present in your authentication system

Check whether either of the following conditions are true:

  • The Google Account ID, found in the assertion's sub field, is in your user database.
  • The email address in the assertion matches a user in your user database.

If either condition is true, the user has already signed up. In that case, return a response like the following:

HTTP/1.1 200 Success
Content-Type: application/json;charset=UTF-8

{
  "account_found":"true",
}

If neither the Google Account ID nor the email address specified in the assertion matches a user in your database, the user hasn't signed up yet. In this case, your token exchange endpoint needs to reply with a HTTP 404 error that specifies "account_found": "false", as in the following example:

HTTP/1.1 404 Not found
Content-Type: application/json;charset=UTF-8

{
  "account_found":"false",
}

ऑटोमैटिक लिंकिंग (इंटेंट)

जब उपयोगकर्ता अपनी Google प्रोफ़ाइल को ऐक्सेस करने की सहमति देता है, तब Google ऐसा अनुरोध भेजता है जिसमें Google के उपयोगकर्ता की पहचान पर हस्ताक्षर किया गया हो. दावे में जानकारी शामिल है, जिसमें उपयोगकर्ता का #Google खाता आईडी, नाम, और ईमेल पता शामिल है. आपके प्रोजेक्ट के लिए कॉन्फ़िगर किया गया टोकन एक्सचेंज एंडपॉइंट, उस अनुरोध को हैंडल करता है.

अगर आपके पुष्टि करने वाले सिस्टम में इससे जुड़ा Google खाता पहले से मौजूद है, तो आपका टोकन एक्सचेंज एंडपॉइंट, उपयोगकर्ता के लिए टोकन दिखाता है. अगर Google खाता किसी मौजूदा उपयोगकर्ता से मेल नहीं खाता है, तो आपका टोकन एक्सचेंज एंडपॉइंट linking_errorगड़बड़ी और वैकल्पिक login_hint दिखाता है.

अनुरोध में यह फ़ॉर्म शामिल होना चाहिए:

POST /token HTTP/1.1
Host: oauth2.example.com
Content-Type: application/x-www-form-urlencoded

grant_type=urn:ietf:params:oauth:grant-type:jwt-bearer&intent=get&assertion=JWT&scope=SCOPES&client_id=GOOGLE_CLIENT_ID&client_secret=GOOGLE_CLIENT_SECRET

आपका टोकन एक्सचेंज एंडपॉइंट इन पैरामीटर को मैनेज कर सकता है:

टोकन एंडपॉइंट पैरामीटर
intent इन अनुरोधों के लिए, इस पैरामीटर की वैल्यू get है.
grant_type एक्सचेंज किए जा रहे टोकन का टाइप. इन अनुरोधों के लिए, इस पैरामीटर की वैल्यू urn:ietf:params:oauth:grant-type:jwt-bearer है.
assertion JSON वेब टोकन (JWT) जो Google उपयोगकर्ता की पहचान की पुष्टि करता है. JWT में उपयोगकर्ता का ईमेल पता, नाम, और ईमेल पते की जानकारी शामिल होती है.
scope ज़रूरी नहीं: ऐसा कोई भी स्कोप जिसके तहत आपने उपयोगकर्ताओं के अनुरोध के लिए, Google को कॉन्फ़िगर किया है.
client_id Google को असाइन किया गया क्लाइंट आईडी.
client_secret वह क्लाइंट सीक्रेट जो आपने Google को असाइन किया है.

get इंटेंट अनुरोधों का जवाब देने के लिए, आपके टोकन एक्सचेंज एंडपॉइंट को नीचे दिए गए तरीके को अपनाना होगा:

  • JWT दावे की पुष्टि करें और उसे डिकोड करें.
  • पक्का करें कि आपके पुष्टि करने वाले सिस्टम में Google खाता पहले से मौजूद है या नहीं.
मान्य करें और JWT अभिकथन को डिकोड करें

आप अपनी भाषा के लिए JWT- डिकोडिंग लाइब्रेरी का उपयोग करके JWT दावे को मान्य और डिकोड कर सकते हैं । टोकन के हस्ताक्षर को सत्यापित करने के लिए, JWK या PEM प्रारूपों में उपलब्ध Google की सार्वजनिक कुंजियों का उपयोग करें।

जब डिकोड किया जाता है, तो JWT अभिकथन निम्नलिखित उदाहरण की तरह दिखता है:

{
  "sub": "1234567890",      // The unique ID of the user's Google Account
  "iss": "https://accounts.google.com",        // The assertion's issuer
  "aud": "123-abc.apps.googleusercontent.com", // Your server's client ID
  "iat": 233366400,         // Unix timestamp of the assertion's creation time
  "exp": 233370000,         // Unix timestamp of the assertion's expiration time
  "name": "Jan Jansen",
  "given_name": "Jan",
  "family_name": "Jansen",
  "email": "jan@gmail.com", // If present, the user's email address
  "email_verified": true,   // true, if Google has verified the email address
  "hd": "example.com",      // If present, the host domain of the user's GSuite email address
                            // If present, a URL to user's profile picture
  "picture": "https://lh3.googleusercontent.com/a-/AOh14GjlTnZKHAeb94A-FmEbwZv7uJD986VOF1mJGb2YYQ",
  "locale": "en_US"         // User's locale, from browser or phone settings
}

टोकन के हस्ताक्षर की पुष्टि करने के अलावा, पुष्टि करें कि दावे का जारीकर्ता ( iss फ़ील्ड) https://accounts.google.com , कि ऑडियंस ( aud फ़ील्ड) आपका असाइन किया गया क्लाइंट ID है, और टोकन की समय सीमा समाप्त नहीं हुई है ( exp मैदान)।

email , email_verified और hd फ़ील्ड का उपयोग करके आप यह निर्धारित कर सकते हैं कि Google होस्ट ईमेल पते के लिए आधिकारिक है या नहीं। उन मामलों में जहां Google आधिकारिक है, उपयोगकर्ता को वर्तमान में वैध खाता स्वामी के रूप में जाना जाता है और आप पासवर्ड या अन्य चुनौतियों के तरीकों को छोड़ सकते हैं। अन्यथा, इन विधियों का उपयोग लिंक करने से पहले खाते को सत्यापित करने के लिए किया जा सकता है।

ऐसे मामले जहां Google आधिकारिक है:

  • email में @gmail.com प्रत्यय है, यह एक जीमेल खाता है।
  • email_verified सत्य है और hd सेट है, यह एक G Suite खाता है।

उपयोगकर्ता जीमेल या जी सूट का उपयोग किए बिना Google खातों के लिए पंजीकरण कर सकते हैं। जब email @gmail.com प्रत्यय नहीं होता है और hd अनुपस्थित होता है तो Google आधिकारिक नहीं होता है और उपयोगकर्ता को सत्यापित करने के लिए पासवर्ड या अन्य चुनौती विधियों की सिफारिश की जाती है। email_verfied भी सही हो सकता है क्योंकि Google ने उपयोगकर्ता को शुरू में सत्यापित किया था जब Google खाता बनाया गया था, हालांकि तृतीय पक्ष ईमेल खाते का स्वामित्व परिवर्तित होने के बाद हो सकता है।

पुष्टि करने वाला Google खाता पहले से मौजूद है या नहीं, इसकी जांच करना

देखें कि इनमें से कोई एक शर्त सही है या नहीं:

  • दावा और #39; sub फ़ील्ड में मिला Google खाता आईडी, आपके उपयोगकर्ता के डेटाबेस में है.
  • दावे में मौजूद ईमेल पता, आपके उपयोगकर्ता डेटाबेस के उपयोगकर्ता से मेल खाता है.

अगर उपयोगकर्ता के लिए कोई खाता मौजूद है, तो ऐक्सेस टोकन जारी करें और JSON ऑब्जेक्ट में अपने एचटीटीपीएस रिस्पॉन्स के मुख्य हिस्से में वैल्यू दिखाएं, जैसे कि नीचे दिया गया उदाहरण:

{
  "token_type": "Bearer",
  "access_token": "ACCESS_TOKEN",

  "expires_in": SECONDS_TO_EXPIRATION
}

कुछ मामलों में, आईडी टोकन के आधार पर खाता जोड़ना उपयोगकर्ता के लिए काम नहीं कर सकता. अगर ऐसा किसी भी वजह से होता है, तो आपके टोकन एक्सचेंज एंडपॉइंट को एचटीटीपी 401 की गड़बड़ी के साथ जवाब देना होगा, जो error=linking_error के बारे में बताता है. नीचे दिया गया उदाहरण देखें:

HTTP/1.1 401 Unauthorized
Content-Type: application/json;charset=UTF-8

{
  "error":"linking_error",
  "login_hint":"foo@bar.com"
}

जब Google को linking_error के साथ 401 गड़बड़ी का जवाब मिलता है, तो Google उपयोगकर्ता को login_hint के साथ आपके ऑथराइज़ेशन एंडपॉइंट पर पैरामीटर के तौर पर भेजता है. उपयोगकर्ता, अपने ब्राउज़र में OAuth लिंकिंग फ़्लो का इस्तेमाल करके खाता लिंक करने की प्रक्रिया पूरी करता है.

Handle account creation via Google Sign-In (create intent)

When a user needs to create an account on your service, Google makes a request to your token exchange endpoint that specifies intent=create.

The request has the following form:

POST /token HTTP/1.1
Host: oauth2.example.com
Content-Type: application/x-www-form-urlencoded

response_type=token&grant_type=urn:ietf:params:oauth:grant-type:jwt-bearer&scope=SCOPES&intent=create&assertion=JWT&client_id=GOOGLE_CLIENT_ID&client_secret=GOOGLE_CLIENT_SECRET

Your token exchange endpoint must able to handle the following parameters:

Token endpoint parameters
intent For these requests, the value of this parameter is create.
grant_type The type of token being exchanged. For these requests, this parameter has the value urn:ietf:params:oauth:grant-type:jwt-bearer.
assertion A JSON Web Token (JWT) that provides a signed assertion of the Google user's identity. The JWT contains information that includes the user's Google Account ID, name, and email address.
client_id The client ID you assigned to Google.
client_secret The client secret you assigned to Google.

The JWT within the assertion parameter contains the user's Google Account ID, name, and email address, which you can use to create a new account on your service.

To respond to the create intent requests, your token exchange endpoint must perform the following steps:

  • Validate and decode the JWT assertion.
  • Validate user information and create new account.
मान्य करें और JWT अभिकथन को डिकोड करें

आप अपनी भाषा के लिए JWT- डिकोडिंग लाइब्रेरी का उपयोग करके JWT दावे को मान्य और डिकोड कर सकते हैं । टोकन के हस्ताक्षर को सत्यापित करने के लिए, JWK या PEM प्रारूपों में उपलब्ध Google की सार्वजनिक कुंजियों का उपयोग करें।

जब डिकोड किया जाता है, तो JWT अभिकथन निम्नलिखित उदाहरण की तरह दिखता है:

{
  "sub": "1234567890",      // The unique ID of the user's Google Account
  "iss": "https://accounts.google.com",        // The assertion's issuer
  "aud": "123-abc.apps.googleusercontent.com", // Your server's client ID
  "iat": 233366400,         // Unix timestamp of the assertion's creation time
  "exp": 233370000,         // Unix timestamp of the assertion's expiration time
  "name": "Jan Jansen",
  "given_name": "Jan",
  "family_name": "Jansen",
  "email": "jan@gmail.com", // If present, the user's email address
  "email_verified": true,   // true, if Google has verified the email address
  "hd": "example.com",      // If present, the host domain of the user's GSuite email address
                            // If present, a URL to user's profile picture
  "picture": "https://lh3.googleusercontent.com/a-/AOh14GjlTnZKHAeb94A-FmEbwZv7uJD986VOF1mJGb2YYQ",
  "locale": "en_US"         // User's locale, from browser or phone settings
}

टोकन के हस्ताक्षर की पुष्टि करने के अलावा, पुष्टि करें कि दावे का जारीकर्ता ( iss फ़ील्ड) https://accounts.google.com , कि ऑडियंस ( aud फ़ील्ड) आपका असाइन किया गया क्लाइंट ID है, और टोकन की समय सीमा समाप्त नहीं हुई है ( exp मैदान)।

email , email_verified और hd फ़ील्ड का उपयोग करके आप यह निर्धारित कर सकते हैं कि Google होस्ट ईमेल पते के लिए आधिकारिक है या नहीं। उन मामलों में जहां Google आधिकारिक है, उपयोगकर्ता को वर्तमान में वैध खाता स्वामी के रूप में जाना जाता है और आप पासवर्ड या अन्य चुनौतियों के तरीकों को छोड़ सकते हैं। अन्यथा, इन विधियों का उपयोग लिंक करने से पहले खाते को सत्यापित करने के लिए किया जा सकता है।

ऐसे मामले जहां Google आधिकारिक है:

  • email में @gmail.com प्रत्यय है, यह एक जीमेल खाता है।
  • email_verified सत्य है और hd सेट है, यह एक G Suite खाता है।

उपयोगकर्ता जीमेल या जी सूट का उपयोग किए बिना Google खातों के लिए पंजीकरण कर सकते हैं। जब email @gmail.com प्रत्यय नहीं होता है और hd अनुपस्थित होता है तो Google आधिकारिक नहीं होता है और उपयोगकर्ता को सत्यापित करने के लिए पासवर्ड या अन्य चुनौती विधियों की सिफारिश की जाती है। email_verfied भी सही हो सकता है क्योंकि Google ने उपयोगकर्ता को शुरू में सत्यापित किया था जब Google खाता बनाया गया था, हालांकि तृतीय पक्ष ईमेल खाते का स्वामित्व परिवर्तित होने के बाद हो सकता है।

Validate user information and create new account

Check whether either of the following conditions are true:

  • The Google Account ID, found in the assertion's sub field, is in your user database.
  • The email address in the assertion matches a user in your user database.

If either condition is true, prompt the user to link their existing account with their Google Account. To do so, respond to the request with an HTTP 401 error that specifies error=linking_error and gives the user's email address as the login_hint. The following is a sample response:

HTTP/1.1 401 Unauthorized
Content-Type: application/json;charset=UTF-8

{
  "error":"linking_error",
  "login_hint":"foo@bar.com"
}

When Google receives a 401 error response with linking_error, Google sends the user to your authorization endpoint with login_hint as a parameter. The user completes account linking using the OAuth linking flow in their browser.

If neither condition is true, create a new user account with the information provided in the JWT. New accounts don't typically have a password set. It's recommended that you add Google Sign-In to other platforms to enable users to log in with Google across the surfaces of your application. Alternatively, you can email the user a link that starts your password recovery flow to allow the user to set a password to sign in on other platforms.

When the creation is completed, issue an access token and return the values in a JSON object in the body of your HTTPS response, like in the following example:

{
  "token_type": "Bearer",
  "access_token": "ACCESS_TOKEN",

  "expires_in": SECONDS_TO_EXPIRATION
}

अपना Google API क्लाइंट आईडी पाना

खाता जोड़ने की रजिस्ट्रेशन प्रक्रिया के दौरान, आपको अपना Google API क्लाइंट आईडी देना होगा.

OAuth लिंकिंग के चरणों को पूरा करते समय, आपने जो प्रोजेक्ट बनाया है उसका इस्तेमाल करके, अपना एपीआई क्लाइंट आईडी पाने के लिए. ऐसा करने के लिए, यह तरीका अपनाएं:

  1. Google API (एपीआई) कंसोल के क्रेडेंशियल पेज खोलें.
  2. कोई Google API प्रोजेक्ट बनाएं या चुनें.

    अगर आपके प्रोजेक्ट में वेब ऐप्लिकेशन के लिए क्लाइंट आईडी नहीं है, तो क्रेडेंशियल बनाएं और gt; OAuth क्लाइंट आईडी पर क्लिक करें. अनुमति वाले JavaScript ऑरिजिन बॉक्स में, अपनी साइट के डोमेन को शामिल करना न भूलें. लोकल टेस्ट या डेवलपमेंट करते समय, आपको http://localhost और http://localhost:<port_number>, दोनों को अनुमति वाले JavaScript ऑरिजिन फ़ील्ड में जोड़ना होगा.

लागू करने की पुष्टि की जा रही है

आप का उपयोग करके अपने कार्यान्वयन को मान्य कर सकते OAuth 2.0 खेल का मैदान उपकरण।

टूल में, निम्न चरणों का पालन करें:

  1. कॉन्फ़िगरेशन क्लिक करें OAuth 2.0 विन्यास विंडो खोलने के लिए।
  2. OAuth प्रवाह क्षेत्र में, क्लाइंट-साइड का चयन करें।
  3. OAuth Endpoints क्षेत्र में, कस्टम का चयन करें।
  4. अपना OAuth 2.0 समापन बिंदु और संबंधित फ़ील्ड में आपके द्वारा Google को निर्दिष्ट क्लाइंट आईडी निर्दिष्ट करें।
  5. चरण 1 अनुभाग में, किसी भी गूगल कार्यक्षेत्रों का चयन नहीं करते। इसके बजाय, इस फ़ील्ड को खाली छोड़ दें या अपने सर्वर के लिए मान्य दायरा टाइप करें (या यदि आप OAuth स्कोप का उपयोग नहीं करते हैं तो एक मनमाना स्ट्रिंग)। यह करने के बाद, अधिकृत एपीआई पर क्लिक करें।
  6. चरण 2 और चरण 3 वर्गों में, OAuth 2.0 प्रवाह के माध्यम से जाना और सत्यापित करें कि प्रत्येक चरण के रूप में इरादा काम करता है।

आप का उपयोग करके अपने कार्यान्वयन को मान्य कर सकते गूगल खाता लिंक करना डेमो उपकरण।

टूल में, निम्न चरणों का पालन करें:

  1. क्लिक करें गूगल से प्रवेश करें बटन में।
  2. वह खाता चुनें जिसे आप लिंक करना चाहते हैं।
  3. सेवा आईडी दर्ज करें।
  4. वैकल्पिक रूप से एक या अधिक क्षेत्र दर्ज करें जिसके लिए आप एक्सेस का अनुरोध करेंगे।
  5. प्रारंभ डेमो क्लिक करें।
  6. संकेत मिलने पर, पुष्टि करें कि आप सहमति दे सकते हैं और लिंकिंग अनुरोध को अस्वीकार कर सकते हैं।
  7. पुष्टि करें कि आपको अपने प्लेटफ़ॉर्म पर पुनर्निर्देशित किया गया है।