AccessToken

This property is used to get or set OracleAccessToken on the connection.

Declaration

// C#
public OracleAccessToken AccessToken { get; set; }

Property Value

An OracleAccessToken object containing a database token and private key, or an access token, used for opening a connection.

Exceptions

  • An InvalidOperationException will be raised if

    • the connection is already open,

    • the value of the TokenAuthentication property is not compatible with the type of token being set. This is applicable for managed ODP.NET and ODP.NET Core only,

    • TokenAuthentication has been set by the application as disabled, or the TokenLocation property is set. This is applicable for managed ODP.NET and ODP.NET Core only.

    • The Credential property is set.

    • Or, the user or proxy information in the connection string is not compatible with token authentication.

  • ArgumentNullException if any argument is null.

  • OracleException if Credential is set.

  • OracleException if user id value is other than /.

  • OracleException if password, proxy user id and proxy password is set.

Description

If the token represents the same identity, then the same OracleAccessToken object should be set on the OracleConnection. The OracleAccessToken object, not the token, is used to identify the connection pool.

If an access token has expired, then OracleConnection.OpenWithNewToken must be called to open a new connection. Since the OracleAccessToken object cannot be modified, it is not possible to specify a refreshed access token on the AccessToken property. However, existing connections can still be dispensed, even after the access token has expired.

In unmanaged ODP.NET, if CPVersion is not set to any value, AccessToken property is set by the application, and Open() method is invoked, then the connection will set the value of CPVersion to 2.0. CPVersion cannot be set to 1.0 in this scenario. Doing so will result in an exception.