क्लाइंट सीक्रेट
संग्रह की मदद से व्यवस्थित रहें
अपनी प्राथमिकताओं के आधार पर, कॉन्टेंट को सेव करें और कैटगरी में बांटें.
.NET के लिए Google API की क्लाइंट लाइब्रेरी इस्तेमाल की जाती है
स्टोर करने के लिए client_secrets.json
फ़ाइलें
client_id
, client_secret
, और अन्य OAuth 2.0 पैरामीटर.
client_secrets.json
यह फ़ाइल, JSON फ़ॉर्मैट वाली फ़ाइल है
जिसमें Client-ID, क्लाइंट सीक्रेट, और अन्य OAuth 2.0 पैरामीटर शामिल हों.
वेब ऐप्लिकेशन के लिए, यहां उदाहरण के तौर पर client_secrets.json
फ़ाइल दी गई है:
{
"web": {
"client_id": "asdfjasdljfasdkjf",
"client_secret": "1912308409123890",
"redirect_uris": ["https://www.example.com/oauth2callback"],
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
"token_uri": "https://accounts.google.com/o/oauth2/token"
}
}
इंस्टॉल किए गए ऐप्लिकेशन के लिए, यहां उदाहरण के तौर पर client_secrets.json
फ़ाइल दी गई है:
{
"installed": {
"client_id": "837647042410-75ifg...usercontent.com",
"client_secret":"asdlkfjaskd",
"redirect_uris": ["http://localhost"],
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
"token_uri": "https://accounts.google.com/o/oauth2/token"
}
}
इस फ़ॉर्मैट में, दो तरह के क्लाइंट आईडी में से किसी एक के बारे में बताया गया है:
web
: वेब ऐप्लिकेशन.
installed
: इंस्टॉल किया गया ऐप्लिकेशन.
web
और installed
सब-ऑब्जेक्ट के पास
ये ज़रूरी सदस्य:
-
client_id
(स्ट्रिंग): क्लाइंट आईडी.
-
client_secret
(स्ट्रिंग): क्लाइंट सीक्रेट.
इस फ़ाइल के अन्य सभी सदस्य वैकल्पिक हैं और
.NET क्लाइंट लाइब्रेरी उनका इस्तेमाल नहीं करती.
वजह
पारंपरिक तौर पर, OAuth 2.0 एंडपॉइंट देने वाली कंपनियों से
जो ग्राहक आईडी को कॉपी करने और चिपकाने के लिए अपनी सेवाओं का इस्तेमाल करते हैं
और क्लाइंट सीक्रेट को रजिस्ट्रेशन पेज से वर्किंग कोड में बदल देता है.
इस तरीके में गड़बड़ी होने की संभावना है और इससे अधूरी जानकारी मिलती है
की ज़रूरी जानकारी शामिल है.
(OAuth 2.0 के लिए, सभी एंडपॉइंट की जानकारी होना भी ज़रूरी है,
और रीडायरेक्ट यूआरआई को कॉन्फ़िगर करना.)
अगर सेवा देने वाली कंपनियां, डाउनलोड किए जा सकने वाले client_secrets.json
उपलब्ध कराती हैं
और क्लाइंट लाइब्रेरी इन फ़ाइलों का उपयोग
तो, OAuth 2.0 को लागू करना आसान होगा. साथ ही, इसमें गड़बड़ी होने की आशंका भी कम होगी.
जब तक कुछ अलग से न बताया जाए, तब तक इस पेज की सामग्री को Creative Commons Attribution 4.0 License के तहत और कोड के नमूनों को Apache 2.0 License के तहत लाइसेंस मिला है. ज़्यादा जानकारी के लिए, Google Developers साइट नीतियां देखें. Oracle और/या इससे जुड़ी हुई कंपनियों का, Java एक रजिस्टर किया हुआ ट्रेडमार्क है.
आखिरी बार 2025-07-26 (UTC) को अपडेट किया गया.
[null,null,["आखिरी बार 2025-07-26 (UTC) को अपडेट किया गया."],[[["\u003cp\u003eThe Google APIs client library for .NET utilizes \u003ccode\u003eclient_secrets.json\u003c/code\u003e files to store OAuth 2.0 credentials like \u003ccode\u003eclient_id\u003c/code\u003e, \u003ccode\u003eclient_secret\u003c/code\u003e, and other parameters.\u003c/p\u003e\n"],["\u003cp\u003eThese JSON files define client ID types as either \u003ccode\u003eweb\u003c/code\u003e for web applications or \u003ccode\u003einstalled\u003c/code\u003e for installed applications, each requiring \u003ccode\u003eclient_id\u003c/code\u003e and \u003ccode\u003eclient_secret\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eUsing \u003ccode\u003eclient_secrets.json\u003c/code\u003e files simplifies OAuth 2.0 implementation by providing a centralized, downloadable configuration instead of manual entry, reducing errors.\u003c/p\u003e\n"]]],[],null,["# Client Secrets\n\nThe Google APIs client library for .NET uses\n`client_secrets.json` files for storing the\n`client_id`, `client_secret`, and other OAuth 2.0 parameters.\n\nA `client_secrets.json`\nfile is a [JSON](http://www.json.org/) formatted file\ncontaining the client ID, client secret, and other OAuth 2.0 parameters.\nHere is an example `client_secrets.json` file for a web application: \n\n```\n{\n \"web\": {\n \"client_id\": \"asdfjasdljfasdkjf\",\n \"client_secret\": \"1912308409123890\",\n \"redirect_uris\": [\"https://www.example.com/oauth2callback\"],\n \"auth_uri\": \"https://accounts.google.com/o/oauth2/auth\",\n \"token_uri\": \"https://accounts.google.com/o/oauth2/token\"\n }\n}\n```\n\n\nHere is an example `client_secrets.json` file for an installed application: \n\n```\n{\n \"installed\": {\n \"client_id\": \"837647042410-75ifg...usercontent.com\",\n \"client_secret\":\"asdlkfjaskd\",\n \"redirect_uris\": [\"http://localhost\"],\n \"auth_uri\": \"https://accounts.google.com/o/oauth2/auth\",\n \"token_uri\": \"https://accounts.google.com/o/oauth2/token\"\n }\n}\n```\n\n\nThe format defines one of two client ID types:\n\n- `web`: Web application.\n- `installed`: Installed application.\n\n\nThe `web` and `installed` sub-objects have\nthe following mandatory members:\n\n- `client_id` (string): The client ID.\n- `client_secret` (string): The client secret.\n\n\nAll the other members of this file are optional and\nthe .NET client library doesn't use them.\n\nMotivation\n----------\n\n\nTraditionally, providers of OAuth 2.0 endpoints have expected\nthose who use their services to copy and paste the client ID\nand client secret from a registration page into working code.\nThis method is error-prone and gives an incomplete picture\nof the information that is needed to get OAuth 2.0 working.\n(OAuth 2.0 also requires knowing all the endpoints,\nand configuring a redirect URI.)\n\nIf service providers provide downloadable `client_secrets.json`\nfiles, and client libraries are prepared to consume these files,\nthen implementing OAuth 2.0 will be easier and less prone to error."]]