OAuth (Open Authorization) is an open standard that enables users to grant third-party applications limited access to their resources on other services without sharing their passwords. OAuth2 is the second and vastly improved version of the protocol, offering more flexible and secure mechanisms for authorization.
In simple terms, OAuth2 allows an application (the client) to obtain permission from the user (the resource owner) via an authorization server to access data on another service (the resource server). The client receives an access token which is then used to access the protected resources.