Unit

ScOAuth2

 

Description

TScOAuth2 is a component designed to perform OAuth authorization version 2.0 on a third-party service and receive tokens from it for accessing the service API. Examples of such OAuth2 services include Google Mail, Microsoft Outlook, FreshBooks, SalesForce, Slack, and any other server that supports the OAuth2 protocol and to which you have access rights to register your application.

During authorization, the component opens the authorization page of the target OAuth2 service in the system browser, launches the built-in HttpServer, and waits for a response from the service. Thus, in order to receive tokens, the user must log in directly on the page of the target service, which is the main task of the OAuth2 protocol.

The TScOAuth2 class has public properties, methods, and events allowing to control the authorization process. Prior to starting the authorization, you must specify the required ClientId, ClientSecret, Scope, AuthorizationUrl, TokenRequestUrl, and WebRedirectUrl properties. Next, you must call either the SignIn or SignInAsync method, as a result of which the obtained tokens will be available in AccessToken and RefreshToken properties. If the SignInAsync method is used, an OnTokenReceive event will be called at the end. In case of a failure the error code will be available in the ResponseError property.

An example of configuring and using a component with different services is located in the \Demos\OAuth2 folder of the SecureBridge library.

General documentation on the OAuth2 protocol is available on the official website, and you also have to review the documentation on the website of the service you intend to use for OAuth2 authorization.

 

See also

AccessToken

AuthorizationUrl

ClientId

ClientSecret

OnTokenReceive

Scope

RefreshToken

ResponseError

SignInAsync

SignIn

TokenRequestUrl

WebRedirectUrl

 

 

 

 

 

SecureBridge Components, Copyright © 2007-2024 Devart. All Rights Reserved. Provide Feedback Visit Forum Request Support