Use the identity API to get an OAuth2 authorization code or access token, which an extension can then use to access user data from a service that supports OAuth2 access (such as Google or Facebook).
OAuth2 flows vary between service provider so, to use this API with a particular service provider, consult their documentation. For example:
The identity API provides the identity.launchWebAuthFlow()
function. This authenticates the user with the service, if necessary, and asks the user to authorize the extension to access data, if necessary. The function completes with an access token or authorization code, depending on the provider.
The extension then completes the OAuth2 flow to get a validated access token, and uses the token in HTTPS requests to access the user's data according to the authorization the user gave.
To use this API, you must have the "identity" API permission.