JSON वेब टोकन
संग्रह की मदद से व्यवस्थित रहें
अपनी प्राथमिकताओं के आधार पर, कॉन्टेंट को सेव करें और कैटगरी में बांटें.
JSON Web Token (JWT) एक ओपन वेब स्टैंडर्ड है. इसका इस्तेमाल, क्लाइंट और सर्वर के बीच जानकारी के आदान-प्रदान की पुष्टि करने और उसे अनुमति देने के लिए किया जाता है. जब कोई ऐप्लिकेशन उपयोगकर्ता, सही भूमिका वाले क्रेडेंशियल से पहली बार साइन इन करता है, तो सर्वर एक एन्कोड किया गया, डिजिटल तौर पर हस्ताक्षर किया गया जेडब्लूटी बनाता है और उसे वापस भेजता है. इसका इस्तेमाल बाद के अनुरोधों के लिए किया जाता है.
इस प्रोसेस से, उपयोगकर्ता की पुष्टि की जाती है. साथ ही, उन्हें उनकी खाता भूमिका के आधार पर रास्तों, सेवाओं, और संसाधनों को ऐक्सेस करने की अनुमति दी जाती है.
Fleet Engine को JSON Web Token (JWT) इस्तेमाल करने की ज़रूरत होती है. ऐसा इसलिए, ताकि कम भरोसेमंद एनवायरमेंट (जैसे कि स्मार्टफ़ोन और ब्राउज़र) से एपीआई के तरीके को कॉल किया जा सके.
JWT आपके सर्वर पर बनता है. इस पर हस्ताक्षर किया जाता है, इसे एन्क्रिप्ट (सुरक्षित) किया जाता है, और क्लाइंट को भेजा जाता है. ऐसा तब तक किया जाता है, जब तक यह खत्म नहीं हो जाता या मान्य नहीं रहता.
मुख्य जानकारी
एपीआई पासकोड के उलट, JWT कम समय के लिए मान्य होते हैं. साथ ही, ये सिर्फ़ उन कार्रवाइयों को सीमित करते हैं जिन्हें भूमिका के हिसाब से करने की अनुमति है. JWT के बारे में ज़्यादा जानकारी के लिए, Wikipedia पर JSON Web Tokens लेख पढ़ें. ऐक्सेस की भूमिकाओं के बारे में ज़्यादा जानने के लिए, इस गाइड में सेवा खाते की भूमिकाएं देखें.
JWT एलिमेंट
JWT में एक हेडर और एक दावा सेक्शन होता है. हेडर सेक्शन में, सेवा खातों से मिली निजी कुंजी और एन्क्रिप्शन एल्गोरिदम जैसी जानकारी होती है. दावे वाले सेक्शन में यह जानकारी होती है: JWT बनाने का समय, JWT के इस्तेमाल की अवधि, JWT के ऐक्सेस का दावा करने वाली सेवाएं, और ऐक्सेस को सीमित करने के लिए अनुमति से जुड़ी अन्य जानकारी. उदाहरण के लिए, डिलीवरी करने वाले वाहन का आईडी.
यहां दी गई टेबल में, सामान्य तौर पर JWT फ़ील्ड के बारे में जानकारी दी गई है. साथ ही, यह भी बताया गया है कि Fleet Engine Cloud प्रोजेक्ट में इन फ़ील्ड की वैल्यू कहां मिल सकती हैं.
JWT हेडर फ़ील्ड
फ़ील्ड |
ब्यौरा |
alg |
इस्तेमाल किया जाने वाला एल्गोरिदम. `RS256`. |
टाइप |
टोकन किस तरह का है. `JWT`. |
बच्चे की प्रोफ़ाइल |
आपके सेवा खाते की निजी कुंजी का आईडी. यह वैल्यू, आपको सेवा खाते की JSON फ़ाइल के private_key_id फ़ील्ड में मिल सकती है. पक्का करें कि आपने सेवा वाले ऐसे खाते की कुंजी का इस्तेमाल किया हो जिसके पास सही लेवल की अनुमतियां हों. |
JWT के दावे वाले फ़ील्ड
फ़ील्ड |
ब्यौरा |
iss |
आपके सेवा खाते का ईमेल पता. यह आपके सेवा खाते की JSON फ़ाइल के client_email फ़ील्ड में मौजूद होता है. |
बदले में खेलने वाला खिलाड़ी |
आपके सेवा खाते का ईमेल पता. यह आपके सेवा खाते की JSON फ़ाइल के client_email फ़ील्ड में मौजूद होता है. |
aud |
आपके सेवा खाते का SERVICE_NAME ,
इस मामले में https://fleetengine.googleapis.com/ |
iat |
यह टाइमस्टैंप बताता है कि JWT कब बनाया गया था. यह 00:00:00 UTC, January 1, 1970 के बाद से बीते हुए सेकंड में बताया जाता है. झुकने के लिए 10 मिनट का समय दें.
अगर टाइमस्टैंप बहुत पुराना है या आने वाले समय का है, तो सर्वर गड़बड़ी की सूचना दे सकता है. |
exp |
वह टाइमस्टैंप जब JWT की समयसीमा खत्म हो जाती है. इसे 00:00:00 UTC, January 1, 1970 के बाद से बीते हुए सेकंड में बताया जाता है. अगर टाइमस्टैंप एक घंटे से ज़्यादा का है, तो अनुरोध पूरा नहीं होगा. |
ऑथराइज़ेशन |
इस्तेमाल के उदाहरण के आधार पर, इसमें deliveryvehicleid , trackingid , taskid या taskids शामिल हो सकते हैं.
अगर taskids तय किए जा रहे हैं, तो अनुमति का दायरा, इनमें से किसी एक फ़ॉर्म में एक कलेक्शन होना चाहिए:
"taskids": ["task_id_one","task_id_two"]
या
"taskids": ["*"] |
Fleet Engine JWT के दावे
Fleet Engine, निजी दावों का इस्तेमाल करता है. निजी दावों का इस्तेमाल करने से यह पक्का होता है कि सिर्फ़
अनुमति वाले क्लाइंट ही अपना डेटा ऐक्सेस कर सकते हैं.
उदाहरण के लिए, जब आपका सर्वर किसी ड्राइवर के मोबाइल डिवाइस के लिए JSON वेब टोकन जारी करता है, तो उसमें vehicleid
दावा या vehicleid
दावा होना चाहिए. साथ ही, उसमें ड्राइवर के वाहन के आईडी की वैल्यू भी होनी चाहिए.deliveryvehicleid
इसके बाद, ड्राइवर की भूमिका के आधार पर, JWT सिर्फ़ उस वाहन के आईडी के लिए ऐक्सेस चालू करते हैं जिसके लिए ड्राइवर को अनुमति मिली है. ये किसी अन्य वाहन के आईडी के लिए ऐक्सेस चालू नहीं करते.
Fleet Engine इन निजी दावों का इस्तेमाल करता है:
मांग के हिसाब से की जाने वाली यात्राएं
-
vehicleid
:
- Driver SDK हमेशा इस दावे का इस्तेमाल करता है. भले ही, वह किसी यात्रा या वाहन पर काम कर रहा हो. Fleet Engine का बैकएंड यह पक्का करता है कि बदलाव करने से पहले, वाहन को अनुरोध की गई यात्रा से जोड़ दिया गया हो.
-
JWT में वाहन और यात्रा, दोनों से जुड़ी कार्रवाइयां शामिल हो सकती हैं. भले ही, इनकी ज़रूरत न हो. इससे JWT पर हस्ताक्षर करने की प्रोसेस को लागू करना आसान हो सकता है.
-
tripid
:
- Consumer SDK हमेशा इस दावे का इस्तेमाल करता है.
-
JWT में वाहन और यात्रा, दोनों से जुड़ी कार्रवाइयां शामिल हो सकती हैं. भले ही, इनकी ज़रूरत न हो. इससे टोकन पर हस्ताक्षर करने की प्रोसेस को लागू करना आसान हो सकता है.
शेड्यूल किए गए टास्क
-
deliveryvehicleid
इसका इस्तेमाल, हर डिलीवरी वाहन के हिसाब से एपीआई को कॉल करते समय करें.
-
taskid
इसका इस्तेमाल, टास्क के हिसाब से एपीआई कॉल करने के लिए किया जाता है.
-
taskids
कॉल करने के लिए, BatchCreateTasksAPI
का इस्तेमाल करें. यह दावा, ऐरे के फ़ॉर्म में होना चाहिए. साथ ही, ऐरे में अनुरोध पूरा करने के लिए ज़रूरी सभी टास्क आईडी शामिल होने चाहिए. delivervehicleid
,
trackingid
या taskid
दावे शामिल न करें.
-
trackingid
GetTaskTrackingInfoAPI
को कॉल करते समय इसका इस्तेमाल करें. यह दावा, अनुरोध में दिए गए ट्रैकिंग आईडी से मेल खाना चाहिए. delivervehicleid
,
taskid
या taskids
दावे शामिल न करें.
आगे क्या करना है
जब तक कुछ अलग से न बताया जाए, तब तक इस पेज की सामग्री को Creative Commons Attribution 4.0 License के तहत और कोड के नमूनों को Apache 2.0 License के तहत लाइसेंस मिला है. ज़्यादा जानकारी के लिए, Google Developers साइट नीतियां देखें. Oracle और/या इससे जुड़ी हुई कंपनियों का, Java एक रजिस्टर किया हुआ ट्रेडमार्क है.
आखिरी बार 2025-09-05 (UTC) को अपडेट किया गया.
[[["समझने में आसान है","easyToUnderstand","thumb-up"],["मेरी समस्या हल हो गई","solvedMyProblem","thumb-up"],["अन्य","otherUp","thumb-up"]],[["वह जानकारी मौजूद नहीं है जो मुझे चाहिए","missingTheInformationINeed","thumb-down"],["बहुत मुश्किल है / बहुत सारे चरण हैं","tooComplicatedTooManySteps","thumb-down"],["पुराना","outOfDate","thumb-down"],["अनुवाद से जुड़ी समस्या","translationIssue","thumb-down"],["सैंपल / कोड से जुड़ी समस्या","samplesCodeIssue","thumb-down"],["अन्य","otherDown","thumb-down"]],["आखिरी बार 2025-09-05 (UTC) को अपडेट किया गया."],[[["\u003cp\u003eJSON Web Tokens (JWTs) are required for API calls to Fleet Engine from low-trust environments like smartphones and browsers, providing authentication and authorization.\u003c/p\u003e\n"],["\u003cp\u003eJWTs are digitally signed by a service account on your server, a trusted environment, and passed to the client for secure communication with Fleet Engine.\u003c/p\u003e\n"],["\u003cp\u003eJWTs contain header and claim sections with information about the private key, encryption algorithm, token lifespan, and authorized access scopes like vehicle or trip IDs.\u003c/p\u003e\n"],["\u003cp\u003eFleet Engine utilizes private claims within JWTs to ensure data security and limit access to specific resources based on assigned roles and vehicle or task IDs.\u003c/p\u003e\n"],["\u003cp\u003eUnlike API keys, JWTs are short-lived and restrict operations to those permitted by the associated service account role, enhancing security.\u003c/p\u003e\n"]]],[],null,["# JSON Web Tokens\n\nA JSON Web Token (JWT) is an open web standard that's used for authenticating\nand authorizing information exchanges between a client and a server. When an app\nuser first signs in with the appropriate role credentials, the server creates\nand returns an encoded, digitally-signed JWT for use with subsequent requests.\nThis process both authenticates the user and authorizes them to access routes,\nservices, and resources based on their account role.\n\nFleet Engine requires the use of **JSON Web Tokens** (JWTs) for API method calls\nfrom **low-trust environments**: smartphones and browsers.\n\nA JWT originates on your server, is signed, encrypted, and passed to the client\nfor subsequent server interactions until it expires or is no longer valid.\n\n**Key details**\n\n- Use [Application Default Credentials](https://google.aip.dev/auth/4110) to authenticate and authorize against Fleet Engine.\n- Use an appropriate service account to sign JWTs. See [Fleet Engine serviceaccount](/maps/documentation/mobility/fleet-engine/essentials/set-up-fleet/service-accounts#fleet_engine_service_account_roles) roles in **Fleet Engine Basics**.\n\nUnlike API keys, JWTs are short lived and limit operations to only those that\nthe role is authorized to perform. For more information on JWTs, see\n[JSON Web Tokens](https://en.wikipedia.org/wiki/JSON_Web_Token) on Wikipedia. For detail on access roles, see\n[Service account roles](/maps/documentation/mobility/fleet-engine/essentials/set-up-fleet/service-accounts) in this guide.\n\nJWT elements\n------------\n\nJWTs contain a header and a claim section. The header section contains\ninformation such as the private key obtained from service accounts, and the\nencryption algorithm. The claim section contains information such as the JWT's\ncreate time, time to live, the services that the JWT claims\naccess to, and other authorization information to scope access; for\nexample, the delivery vehicle ID.\n\nThe following table provides descriptive details about JWT fields in general,\nas well as specific information about where you can find the values for these\nfields in your Fleet Engine Cloud project.\n\n| **Field** | **Description** |\n|-----------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| alg | The algorithm to use. \\`RS256\\`. |\n| typ | The type of token. \\`JWT\\`. |\n| kid | Your service account's private key ID. You can find this value in the `private_key_id` field of your service account JSON file. Make sure to use a key from a service account with the correct level of permissions. |\n[JWT header fields]\n\n| **Field** | **Description** |\n|---------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| iss | Your service account's email address, found in the `client_email` field of your service account JSON file. |\n| sub | Your service account's email address, found in the `client_email` field of your service account JSON file. |\n| aud | Your service account's `SERVICE_NAME`, in this case `https://fleetengine.googleapis.com/` |\n| iat | The timestamp when the JWT was created, specified in seconds elapsed since 00:00:00 `UTC, January 1, 1970`. Allow 10 minutes for skew. If the timestamp is too far in the past, or in the future, the server might report an error. |\n| exp | The timestamp when the JWT expires, specified in seconds elapsed since `00:00:00 UTC, January 1, 1970`. The request fails if the timestamp is more than one hour in the future. |\n| authorization | Depending on the use case, may contain `deliveryvehicleid`, `trackingid`, `taskid`, or `taskids`. If specifying taskids, the authorization scope must be an array in one of the following forms: `\"taskids\": [\"task_id_one\",\"task_id_two\"]` or `\"taskids\": [\"*\"]` |\n[JWT claims fields]\n\n### Fleet Engine JWT claims\n\nFleet Engine uses private claims. Using private claims ensures that only\nauthorized clients can access their own data.\n\nFor example, when your server issues a JSON Web Token for a driver's mobile\ndevice, it should contain either the `vehicleid` claim or the\n`deliveryvehicleid` claim with the value of that driver's vehicle ID. Then,\ndepending on the driver role, JWTs enable access only for the specific vehicle\nID and not any other arbitrary vehicle ID.\n\nFleet Engine uses the following private claims: \n\n### On-demand trips\n\n- **`vehicleid`** :\n - The Driver SDK always uses this claim, whether operating on a trip or vehicle. The Fleet Engine backend assures that the vehicle is associated with the requested trip before doing the modification.\n - The JWT can cover both vehicle and trip operations, even if not required, which may simplify the JWT signing implementation.\n- **`tripid`** :\n - The Consumer SDK always uses this claim.\n - The JWT can cover both vehicle and trip operations, even if not required, which may simplify the token signing implementation.\n\n### Scheduled tasks\n\n- `deliveryvehicleid`\n\n Use when calling per-delivery-vehicle\n APIs.\n- `taskid`\n\n Use when calling per-task APIs.\n- `taskids`\n\n Use when calling\n `BatchCreateTasksAPI`. This claim must be in array form,\n and the array should contain all task IDs necessary to complete the\n request. Don't include `delivervehicleid`,\n `trackingid`, or `taskid` claims.\n- `trackingid`\n\n Use when calling the\n `GetTaskTrackingInfoAPI`. The claim must match the tracking\n ID in the request. Don't include `delivervehicleid`,\n `taskid`, or `taskids` claims.\n\nWhat's next\n-----------\n\n- Read about [Fleet Engine security design](/maps/documentation/mobility/fleet-engine/essentials/set-up-fleet/security-design) to understand the complete authentication flow.\n- Learn how to [Issue JSON Web Tokens](/maps/documentation/mobility/fleet-engine/essentials/set-up-fleet/issue-jwt) from your server."]]