با مجموعهها، منظم بمانید
ذخیره و طبقهبندی محتوا براساس اولویتهای شما.
برنامههای وب برای تماس ایمن با Google API باید یک نشانه دسترسی دریافت کنند.
کتابخانه جاوا اسکریپت خدمات هویت گوگل هم از احراز هویت برای ورود به سیستم کاربر و هم مجوز برای به دست آوردن رمز دسترسی برای استفاده با APIهای Google پشتیبانی می کند. این کتابخانه فقط برای استفاده در مرورگرها در نظر گرفته شده است.
احراز هویت مشخص میکند که شخص چه کسی است، و معمولاً به عنوان ثبت نام یا ورود به سیستم کاربر شناخته میشود. مجوز فرآیند اعطای یا رد دسترسی به داده ها یا منابع است. این شامل کسب و مدیریت رضایت کاربر، محدود کردن مقدار داده یا منابع به اشتراک گذاشته شده با دامنهها، و بازیابی رمز دسترسی برای استفاده با Google API است.
این راهنماها موضوعات مجوز و اشتراک داده را پوشش می دهد.
نحوه عملکرد مجوز کاربر، مراحل جداگانه مجوز کاربر را به تفصیل شرح میدهد و شامل نمونههای گفتگوی کاربر است.
اگر به دنبال کمک برای احراز هویت و نحوه اجرای ثبت نام و ورود کاربر به سیستم هستید، به ورود با Google مراجعه کنید.
این کتابخانه برای استفاده با چارچوب های جاوا اسکریپت سمت سرور مانند Node.js در نظر گرفته نشده است، در عوض از کتابخانه مشتری Node.js Google استفاده می کند.
چه چیزی تغییر کرده است
برای کاربران، کتابخانه Google Identity Services پیشرفتهای کاربردی متعددی را نسبت به کتابخانههای جاوا اسکریپت قبلی ارائه میکند، از جمله:
احراز هویت برای ورود به سیستم کاربر، و مجوز برای به دست آوردن رمز دسترسی برای فراخوانی APIهای Google، اکنون دارای دو جریان کاربر مجزا و مجزا است. یکی برای ورود به سیستم و دیگری برای رضایت در حین مجوز، با جریانهای کاربر مجزا برای تشخیص واضح اینکه شما چه کسی هستید و چه برنامهای میتواند انجام دهد.
دید بهبود یافته و کنترل دقیق اشتراک گذاری داده ها در حین رضایت کاربر .
دیالوگ های پاپ آپ مبتنی بر مرورگر برای کاهش اصطکاک، که نیازی به ترک سایت شما توسط کاربران ندارد:
یک رمز دسترسی از Google دریافت کنید، یا
یک کد مجوز به پلتفرم باطن خود ارسال کنید.
برای توسعه دهندگان، تمرکز ما کاهش پیچیدگی، بهبود امنیت، و ادغام شما تا حد امکان سریع و آسان بوده است. برخی از این تغییرات عبارتند از:
احراز هویت کاربر برای ورود به سیستم و مجوزی که برای به دست آوردن رمز دسترسی برای فراخوانی APIهای Google استفاده میشود، دو مجموعه مجزا و مجزا از شیها و روشهای جاوا اسکریپت هستند. این امر پیچیدگی و مقدار جزئیات مورد نیاز برای اجرای احراز هویت یا مجوز را کاهش می دهد.
اکنون یک کتابخانه جاوا اسکریپت از هر دو زیر پشتیبانی می کند:
جریان ضمنی OAuth 2.0، برای به دست آوردن یک نشانه دسترسی برای استفاده در مرورگر استفاده می شود
جریان کد مجوز OAuth 2.0، همچنین به عنوان دسترسی آفلاین شناخته می شود، و تحویل ایمن یک کد مجوز را به پلتفرم پشتیبان شما آغاز می کند، جایی که می توان آن را با یک نشانه دسترسی و رمز بازخوانی مبادله کرد. پیش از این، این جریانها تنها با استفاده از کتابخانههای متعدد و از طریق تماس مستقیم با نقاط پایانی OAuth 2.0 در دسترس بودند. یک کتابخانه واحد زمان و تلاش ادغام شما را کاهش می دهد، به جای اینکه چندین کتابخانه و مفاهیم OAuth 2.0 را گنجانده و یاد بگیرید، می توانید روی یک رابط واحد و یکپارچه تمرکز کنید.
غیر جهت از طریق توابع سبک دریافت کننده برای سادگی و خوانایی حذف شده است.
هنگام رسیدگی به پاسخهای مجوز، شما انتخاب میکنید که از یک Promise برای انجام درخواستها استفاده کنید یا نه، به جای اینکه این تصمیم برای شما گرفته شود.
ماژول gapi.auth2 و اشیا و روشهای مرتبط دیگر بهطور خودکار برای شما در پشت صحنه بارگیری نمیشوند و با اشیاء و روشهای کتابخانه خدمات هویت Google واضحتر جایگزین شدهاند.
بهروزرسانی خودکار نشانههای دسترسی منقضی شده برای بهبود امنیت و آگاهی کاربر حذف شده است. پس از انقضای رمز دسترسی، برنامه شما باید پاسخهای خطای Google API را رسیدگی کند، درخواست کند و یک نشانه دسترسی جدید و معتبر دریافت کند.
برای پشتیبانی از تفکیک واضح لحظههای احراز هویت و مجوز، ورود همزمان کاربر به برنامه و حساب Google وی و در عین حال صدور رمز دسترسی دیگر پشتیبانی نمیشود. پیش از این، درخواست رمز دسترسی، کاربران را به حساب Google خود نیز وارد میکرد و اعتبار رمز JWT ID را برای احراز هویت کاربر برمیگرداند.
برای افزایش امنیت و حریم خصوصی کاربر، به ازای هر کاربری که برای مجوز صادر میشود، از اصل کمترین امتیاز پیروی میکند و فقط یک نشانه دسترسی و اطلاعات مورد نیاز برای مدیریت آن را شامل میشود.
تاریخ آخرین بهروزرسانی 2023-12-02 بهوقت ساعت هماهنگ جهانی.
[null,null,["تاریخ آخرین بهروزرسانی 2023-12-02 بهوقت ساعت هماهنگ جهانی."],[[["\u003cp\u003eGoogle Identity Services JavaScript library enables secure access to Google APIs via access tokens and supports user authentication.\u003c/p\u003e\n"],["\u003cp\u003eThe library offers separate, streamlined user flows for sign-in (authentication) and consent (authorization) for enhanced user experience and control.\u003c/p\u003e\n"],["\u003cp\u003eDevelopers benefit from reduced complexity, improved security, and easier integration with features like a unified library for both implicit and authorization code flows.\u003c/p\u003e\n"],["\u003cp\u003eGoogle Identity Services prioritizes user privacy and security through measures like least privilege credentials and explicit access token refresh handling.\u003c/p\u003e\n"],["\u003cp\u003eThe library is exclusively for browser-based applications and should not be used with server-side JavaScript frameworks like Node.js.\u003c/p\u003e\n"]]],[],null,["# Authorizing for Web\n\nWeb apps must obtain an access token to securely call Google APIs.\n\nThe Google Identity Services JavaScript library supports both authentication for\nuser sign-in and authorization to obtain an access token for use with Google\nAPIs. The library is intended only for use in browsers.\n\nAuthentication establishes who someone is, and is commonly referred to as user\nsign-up or sign-in. Authorization is the process of granting or rejecting access\nto data or resources. It includes obtaining and managing user consent, limiting\nthe amount of data or resources shared with scopes, and retrieving an access\ntoken for use with Google APIs.\n\nThese guides cover authorization and data sharing topics.\n\n[How user authorization works](/identity/oauth2/web/guides/how-user-authz-works) describes the individual steps of user\nauthorization in detail and includes user dialog examples.\n\nIf you are looking for help with authentication and how to implement user\nsign-up and sign-in see [Sign In With Google](/identity/gsi/web/guides/overview).\n| **Note:** The `email`, `profile`, and `openid` scopes are used for user authentication. If your app only uses these scopes [Sign In With Google](/identity/gsi/web) is recommended instead.\n\nThis library is not intended for use with server-side JavaScript frameworks such\nas Node.js, instead use Google's [Node.js](https://github.com/googleapis/google-api-nodejs-client)\nclient library.\n\nWhat's changed\n--------------\n\nFor users, the Google Identity Services library offers numerous usability\nimprovements over earlier JavaScript libraries, including:\n\n- Authentication for user sign-in, and authorization to obtain an access token to call Google APIs, now have two separate and distinct user flows; one for [sign-in](/identity/gsi/web/guides/overview#how_it_works) and another for [consent](/identity/oauth2/web/guides/how-user-authz-works#user_consent) during authorization, with separate user flows to clearly differentiate who you are, from what an app can do.\n- Improved visibility and granular control of data sharing during [user\n consent](/identity/oauth2/web/guides/how-user-authz-works#user_consent).\n- Browser based pop-up dialogs to reduce friction, and which do not require users to leave your site to:\n - obtain an access token from Google, or\n - send an authorization code to your backend platform.\n\nFor developers, our focus has been to reduce complexity, improve security, and\nmake your integration as quick and easy as possible. Some of these changes are:\n\n- User [authentication](/identity/gsi/web/reference/js-reference) for sign-in, and [authorization](/identity/oauth2/web/reference/js-reference) used to obtain an access token to call Google APIs, are two separate and distinct sets of JavaScript objects, and methods. This reduces the complexity and amount of detail required to implement authentication or authorization.\n- A single JavaScript library now supports both the:\n - OAuth 2.0 implicit flow, used to obtain an access token for use in-browser\n - OAuth 2.0 authorization code flow, also known as offline access, and initiates securely delivering an authorization code to your backend platform, where it can be exchanged for an access token and refresh token. Previously, these flows were only available by using multiple libraries and through direct calls to OAuth 2.0 endpoints. A single library decreases your integration time and effort, instead of including and learning multiple libraries and OAuth 2.0 concepts you can focus on a single, unified interface.\n- Indirection through getter style functions has been removed for simplicity and readability.\n- When handling authorization responses you choose whether or not to use a [Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) to fulfill requests, instead of that decision being made for you.\n- The [Google API Client Library for JavaScript](https://github.com/google/google-api-javascript-client) has been updated with these changes:\n - the `gapi.auth2` module and associated objects and methods are no longer automatically loaded for you behind the scenes, and have been replaced with more explicit Google Identity Services library objects and methods.\n - Automatic refresh of expired access tokens has been removed to improve user security and awareness. After an access token expires your app must handle Google API error responses, request, and obtain a new, valid access token.\n - To support a clear separation of authentication and authorization moments, simultaneously signing a user in to your app and to their Google Account while also issuing an access token is no longer supported. Previously, requesting an access token also signed users into their Google Account and returned a JWT ID token credential for user authentication.\n- To increase user security and privacy, per user [credentials](/identity/oauth2/web/guides/migration-to-gis#example_credentials) issued for authorization follow the principle of least privilege by including only an access token and information required to manage it."]]