Class AuthorizationException
จัดทุกอย่างให้เป็นระเบียบอยู่เสมอด้วยคอลเล็กชัน
บันทึกและจัดหมวดหมู่เนื้อหาตามค่ากำหนดของคุณ
ข้อยกเว้นการให้สิทธิ์
ข้อผิดพลาดที่แสดงเพื่อทริกเกอร์ให้การ์ดการให้สิทธิ์แสดงต่อผู้ใช้
CardService.newAuthorizationException()
.setAuthorizationUrl('http://auth.com/')
.setResourceDisplayName('Example Resource')
.throwException();
เอกสารประกอบโดยละเอียด
printJson()
พิมพ์การแสดง JSON ของออบเจ็กต์นี้ การดำเนินการนี้มีไว้สำหรับการแก้ไขข้อบกพร่องเท่านั้น
รีเทิร์น
String
setAuthorizationUrl(authUrl)
ตั้งค่า URL การให้สิทธิ์ที่ระบบจะนำผู้ใช้ไปยังจากข้อความแจ้งการให้สิทธิ์ ต้องระบุ
พารามิเตอร์
ชื่อ | ประเภท | คำอธิบาย |
authUrl | String | URL การให้สิทธิ์ที่จะตั้งค่า |
รีเทิร์น
AuthorizationException
— ออบเจ็กต์นี้สําหรับการต่อเชื่อม
setCustomUiCallback(callback)
ชื่อฟังก์ชันที่จะเรียกใช้เพื่อสร้างพรอมต์การให้สิทธิ์ที่กําหนดเอง ไม่บังคับ
พารามิเตอร์
ชื่อ | ประเภท | คำอธิบาย |
callback | String | ชื่อของฟังก์ชันที่สร้างข้อความแจ้งให้สิทธิ์ที่กำหนดเอง |
รีเทิร์น
AuthorizationException
— ออบเจ็กต์นี้สําหรับการต่อเชื่อม
setResourceDisplayName(name)
ตั้งค่าชื่อที่จะแสดงต่อผู้ใช้เมื่อขอสิทธิ์ ต้องระบุ
พารามิเตอร์
ชื่อ | ประเภท | คำอธิบาย |
name | String | ชื่อที่แสดง |
รีเทิร์น
AuthorizationException
— ออบเจ็กต์นี้สําหรับการต่อเชื่อม
throwException()
ทริกเกอร์ให้ระบบแสดงข้อยกเว้นนี้
เนื้อหาของหน้าเว็บนี้ได้รับอนุญาตภายใต้ใบอนุญาตที่ต้องระบุที่มาของครีเอทีฟคอมมอนส์ 4.0 และตัวอย่างโค้ดได้รับอนุญาตภายใต้ใบอนุญาต Apache 2.0 เว้นแต่จะระบุไว้เป็นอย่างอื่น โปรดดูรายละเอียดที่นโยบายเว็บไซต์ Google Developers Java เป็นเครื่องหมายการค้าจดทะเบียนของ Oracle และ/หรือบริษัทในเครือ
อัปเดตล่าสุด 2025-07-26 UTC
[null,null,["อัปเดตล่าสุด 2025-07-26 UTC"],[[["\u003cp\u003e\u003ccode\u003eAuthorizationException\u003c/code\u003e triggers an authorization card to obtain user authorization.\u003c/p\u003e\n"],["\u003cp\u003eIt allows setting an authorization URL, a resource display name, and optionally, a custom authorization prompt.\u003c/p\u003e\n"],["\u003cp\u003eDevelopers use \u003ccode\u003esetAuthorizationUrl()\u003c/code\u003e, \u003ccode\u003esetResourceDisplayName()\u003c/code\u003e, and \u003ccode\u003esetCustomUiCallback()\u003c/code\u003e to configure the authorization request.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003ethrowException()\u003c/code\u003e initiates the authorization flow, prompting the user to grant access.\u003c/p\u003e\n"],["\u003cp\u003eDebugging is facilitated by \u003ccode\u003eprintJson()\u003c/code\u003e which outputs the object's JSON representation.\u003c/p\u003e\n"]]],[],null,["# Class AuthorizationException\n\nAuthorizationException\n\nAn error that can be returned to trigger an authorization card to be shown to the user.\n\n```javascript\nCardService.newAuthorizationException()\n .setAuthorizationUrl('http://auth.com/')\n .setResourceDisplayName('Example Resource')\n .throwException();\n``` \n\n### Methods\n\n| Method | Return type | Brief description |\n|-----------------------------------------------------------------|-----------------------------|---------------------------------------------------------------------------------|\n| [printJson()](#printJson()) | `String` | Prints the JSON representation of this object. |\n| [setAuthorizationUrl(authUrl)](#setAuthorizationUrl(String)) | [AuthorizationException](#) | Sets the authorization URL that user is taken to from the authorization prompt. |\n| [setCustomUiCallback(callback)](#setCustomUiCallback(String)) | [AuthorizationException](#) | The name of a function to call to generate a custom authorization prompt. |\n| [setResourceDisplayName(name)](#setResourceDisplayName(String)) | [AuthorizationException](#) | Sets the name that is displayed to the user when asking for authorization. |\n| [throwException()](#throwException()) | `void` | Triggers this exception to be thrown. |\n\nDetailed documentation\n----------------------\n\n### `print``Json()`\n\nPrints the JSON representation of this object. This is for debugging only.\n\n#### Return\n\n\n`String`\n\n*** ** * ** ***\n\n### `set``Authorization``Url(authUrl)`\n\nSets the authorization URL that user is taken to from the authorization prompt. Required.\n\n#### Parameters\n\n| Name | Type | Description |\n|-------------|----------|-------------------------------|\n| `auth``Url` | `String` | The authorization URL to set. |\n\n#### Return\n\n\n[AuthorizationException](#) --- This object, for chaining.\n\n*** ** * ** ***\n\n### `set``Custom``Ui``Callback(callback)`\n\nThe name of a function to call to generate a custom authorization prompt. Optional.\n\n#### Parameters\n\n| Name | Type | Description |\n|------------|----------|------------------------------------------------------------------------|\n| `callback` | `String` | The name of the function that generates a custom authorization prompt. |\n\n#### Return\n\n\n[AuthorizationException](#) --- This object, for chaining.\n\n*** ** * ** ***\n\n### `set``Resource``Display``Name(name)`\n\nSets the name that is displayed to the user when asking for authorization. Required.\n\n#### Parameters\n\n| Name | Type | Description |\n|--------|----------|-------------------|\n| `name` | `String` | The display name. |\n\n#### Return\n\n\n[AuthorizationException](#) --- This object, for chaining.\n\n*** ** * ** ***\n\n### `throw``Exception()`\n\nTriggers this exception to be thrown."]]