使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
什么是令牌?
Fleet Engine 要求从低信任环境(智能手机和浏览器)进行 API 方法调用时,使用 JSON Web 令牌 (JWT)。
JWT 起源于您的服务器,经过签名和加密后传递给客户端,以便在到期或失效之前进行后续服务器互动。
关键详情
如需详细了解 JSON Web 令牌,请参阅车队引擎必备知识中的 JSON Web 令牌。
客户如何获取令牌?
当驾驶员或使用方使用适当的授权凭据登录您的应用后,从该设备发出的任何更新都必须使用适当的授权令牌,这些令牌会将应用的权限传达给车队引擎。
作为开发者,您的客户端实现应能够执行以下操作:
- 从您的服务器提取 JSON Web 令牌。
- 在令牌过期之前重复使用该令牌,以尽可能减少令牌刷新次数。
- 在令牌过期时刷新令牌。
AuthTokenFactory
类会在位置信息更新时生成授权令牌。SDK 必须将令牌与更新信息打包在一起,以便发送到车队引擎。在初始化 SDK 之前,请确保您的服务器端实现可以签发令牌。
如需详细了解 Fleet Engine 服务所需的令牌,请参阅 Fleet Engine 的签发 JSON Web 令牌。
授权令牌提取器示例
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-01-16。
[[["易于理解","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"]],["最后更新时间 (UTC):2025-01-16。"],[[["Fleet Engine requires JSON Web Tokens (JWTs) for API calls from low-trust environments like smartphones and browsers, which are signed by a service account on your server."],["Your backend should use standard Application Default Credentials to authenticate with Fleet Engine."],["Client applications need to fetch, reuse, and refresh JWTs from your server for authorization when interacting with Fleet Engine."],["The `AuthTokenFactory` class helps generate these authorization tokens, which are then included with location updates sent to Fleet Engine."]]],["JSON Web Tokens (JWTs) are required for API calls from low-trust environments like smartphones and browsers. Clients fetch JWTs from the server upon user login and reuse them until expiry, refreshing them as needed. The `AuthTokenFactory` class generates tokens packaged with update information for Fleet Engine. Your server must use Application Default Credentials and appropriate service accounts to sign and issue JWTs, communicating app permissions to Fleet Engine. Client implementations must fetch, reuse, and refresh these tokens.\n"]]