ConfigurationFile

This property sets the configuration file location where the OCI token authentication values can be found.

Declaration

// C#
public string ConfigurationFile { set; }

Exceptions

An InvalidOperationException will be raised if the application tries to modify an ociTokenAuthenticationConfiguration object by setting this property once a connection has opened using that configuration object.

Remarks

This parameter is applicable to the OCI API key and OCI interactive authentication flows only and is optional.

Whenever this parameter is provided, the entire directory path including the configuration file name should be specified. ODP.NET does not use the standard file name if it is missing. Example of setting configuration file is C:\Users\admin\.oci\config. Skipping the file name config from the path like C:\Users\admin\.oci\, will throw an error.

If this parameter is not set, then ODP.NET uses the OCI configuration file in the default location: C:/<user-profile>/.oci/config. If the parameter is not set and the default configuration file is not found, then the user is prompted on the console to provide a region id for the OCI interactive authentication flow. A list of possible region ids will be displayed to the user. In the case of the OCI API key flow, the user will see an error.

On Windows, the Oracle HOME and USERPROFILE environment variables are used for the default directory location if they are set. Otherwise, Oracle HOMEPATH and HOMEDRIVE environment variables are used.

Sample Code

OracleConnection conn = new OracleConnection(constr);
conn.TokenAuthentication = OracleTokenAuth.OciApiKey;
OciTokenAuthentication tokenconfig = new OciTokenAuthentication{
	ConfigurationFile = "<CONFIGURATION FILE>",
	Profile = "<PROFILE>",
	Compartment = "<COMPARTMENT OCID>",
	Database = "<DATABASE OCID>"
}
conn.UseOciTokenAuthentication(tokenConfig);
conn.Open();
conn.Close();