Compartir a través de


ServiceClient Constructors

Definition

Overloads

ServiceClient(String, SecureString, String, String, String, String, Boolean, Boolean, OrganizationDetail, String, Uri, PromptBehavior, String, ILogger)

Log in with OAuth for On-Premises connections.

ServiceClient(String, SecureString, String, String, Boolean, OrganizationDetail, String, Uri, PromptBehavior, Boolean, String, ILogger)

Log in with OAuth for online connections,

Utilizes the discovery system to resolve the correct endpoint to use given the provided server orgName, user name and password.

ServiceClient(X509Certificate2, StoreName, String, Uri, String, Boolean, Boolean, OrganizationDetail, String, Uri, ILogger)

Log in with Certificate Auth On-Premises connections.

ServiceClient(String, SecureString, Uri, Boolean, String, Uri, PromptBehavior, Boolean, String, ILogger)

Log in with OAuth for online connections,

Will attempt to connect directly to the URL provided for the API endpoint.

ServiceClient(String, ILogger)

ServiceClient to accept the connectionstring as a parameter

ServiceClient(Uri, String, String, Boolean, ILogger)

ClientID \ ClientSecret Based Authentication flow.

ServiceClient(Uri, String, SecureString, Boolean, ILogger)

ClientID \ ClientSecret Based Authentication flow, allowing for Secure Client ID passing.

ServiceClient(Uri, Func<String,Task<String>>, Boolean, ILogger)

Creates an instance of ServiceClient who's authentication is managed by the caller. This requires the caller to implement a function that will accept the InstanceURI as a string will return the access token as a string on demand when the ServiceClient requires it. This approach is recommended when working with WebApplications or applications that are required to implement an on Behalf of flow for user authentication.

ServiceClient(ConnectionOptions, Boolean, ConfigurationOptions)

Creating the ServiceClient Connection with a ConnectionOptions Object and ConfigurationOptions Object. This allows for deferred create of a Dataverse Service Client.

ServiceClient(X509Certificate2, StoreName, String, Uri, Boolean, OrganizationDetail, String, Uri, ILogger)

Log in with Certificate Auth OnLine connections. This requires the org API URI.

ServiceClient(String, SecureString, String, String, String, String, Boolean, Boolean, OrganizationDetail, String, Uri, PromptBehavior, String, ILogger)

Log in with OAuth for On-Premises connections.

public ServiceClient (string userId, System.Security.SecureString password, string domain, string hostName, string port, string orgName, bool useSsl, bool useUniqueInstance, Microsoft.Xrm.Sdk.Discovery.OrganizationDetail orgDetail, string clientId, Uri redirectUri, Microsoft.PowerPlatform.Dataverse.Client.Auth.PromptBehavior promptBehavior = Microsoft.PowerPlatform.Dataverse.Client.Auth.PromptBehavior.Auto, string tokenCacheStorePath = default, Microsoft.Extensions.Logging.ILogger logger = default);
new Microsoft.PowerPlatform.Dataverse.Client.ServiceClient : string * System.Security.SecureString * string * string * string * string * bool * bool * Microsoft.Xrm.Sdk.Discovery.OrganizationDetail * string * Uri * Microsoft.PowerPlatform.Dataverse.Client.Auth.PromptBehavior * string * Microsoft.Extensions.Logging.ILogger -> Microsoft.PowerPlatform.Dataverse.Client.ServiceClient
Public Sub New (userId As String, password As SecureString, domain As String, hostName As String, port As String, orgName As String, useSsl As Boolean, useUniqueInstance As Boolean, orgDetail As OrganizationDetail, clientId As String, redirectUri As Uri, Optional promptBehavior As PromptBehavior = Microsoft.PowerPlatform.Dataverse.Client.Auth.PromptBehavior.Auto, Optional tokenCacheStorePath As String = Nothing, Optional logger As ILogger = Nothing)

Parameters

userId
String

User Id supplied

password
SecureString

Password for login

domain
String

Domain

hostName
String

Host name of the server that is hosting the Dataverse web service

port
String

Port number on the Dataverse Host Server ( usually 444 )

orgName
String

Organization name for the Dataverse Instance.

useSsl
Boolean

if true, https:// used

useUniqueInstance
Boolean

if set, will force the system to create a unique connection

orgDetail
OrganizationDetail

Dataverse Org Detail object, this is returned from a query to the Dataverse Discovery Server service. not required.

clientId
String

The registered client Id on Azure portal.

redirectUri
Uri

The redirect URI application will be redirected post OAuth authentication.

promptBehavior
PromptBehavior

The prompt Behavior.

tokenCacheStorePath
String

(Optional)The token cache path where token cache file is placed. if string.empty, will use default cache file store, if null, will use in memory cache

logger
ILogger

Logging provider ILogger

Applies to

ServiceClient(String, SecureString, String, String, Boolean, OrganizationDetail, String, Uri, PromptBehavior, Boolean, String, ILogger)

Log in with OAuth for online connections,

Utilizes the discovery system to resolve the correct endpoint to use given the provided server orgName, user name and password.

public ServiceClient (string userId, System.Security.SecureString password, string regionGeo, string orgName, bool useUniqueInstance, Microsoft.Xrm.Sdk.Discovery.OrganizationDetail orgDetail, string clientId, Uri redirectUri, Microsoft.PowerPlatform.Dataverse.Client.Auth.PromptBehavior promptBehavior = Microsoft.PowerPlatform.Dataverse.Client.Auth.PromptBehavior.Auto, bool useDefaultCreds = false, string tokenCacheStorePath = default, Microsoft.Extensions.Logging.ILogger logger = default);
new Microsoft.PowerPlatform.Dataverse.Client.ServiceClient : string * System.Security.SecureString * string * string * bool * Microsoft.Xrm.Sdk.Discovery.OrganizationDetail * string * Uri * Microsoft.PowerPlatform.Dataverse.Client.Auth.PromptBehavior * bool * string * Microsoft.Extensions.Logging.ILogger -> Microsoft.PowerPlatform.Dataverse.Client.ServiceClient
Public Sub New (userId As String, password As SecureString, regionGeo As String, orgName As String, useUniqueInstance As Boolean, orgDetail As OrganizationDetail, clientId As String, redirectUri As Uri, Optional promptBehavior As PromptBehavior = Microsoft.PowerPlatform.Dataverse.Client.Auth.PromptBehavior.Auto, Optional useDefaultCreds As Boolean = false, Optional tokenCacheStorePath As String = Nothing, Optional logger As ILogger = Nothing)

Parameters

userId
String

User Id supplied

password
SecureString

Password for login

regionGeo
String

Region where server is provisioned in for login

orgName
String

Name of the organization to connect

useUniqueInstance
Boolean

if set, will force the system to create a unique connection

orgDetail
OrganizationDetail

Dataverse Org Detail object, this is is returned from a query to the Dataverse Discovery Server service. not required.

clientId
String

The registered client Id on Azure portal.

redirectUri
Uri

The redirect URI application will be redirected post OAuth authentication.

promptBehavior
PromptBehavior

The prompt Behavior.

useDefaultCreds
Boolean

(optional) If true attempts login using current user ( Online )

tokenCacheStorePath
String

(Optional)The token cache path where token cache file is placed. if string.empty, will use default cache file store, if null, will use in memory cache

logger
ILogger

Logging provider ILogger

Remarks

Uses the Discovery service to resolve the correct endpoint to use when provided the service organization name, user name, and password.

Applies to

ServiceClient(X509Certificate2, StoreName, String, Uri, String, Boolean, Boolean, OrganizationDetail, String, Uri, ILogger)

Log in with Certificate Auth On-Premises connections.

public ServiceClient (System.Security.Cryptography.X509Certificates.X509Certificate2 certificate, System.Security.Cryptography.X509Certificates.StoreName certificateStoreName, string certificateThumbPrint, Uri instanceUrl, string orgName, bool useSsl, bool useUniqueInstance, Microsoft.Xrm.Sdk.Discovery.OrganizationDetail orgDetail, string clientId, Uri redirectUri, Microsoft.Extensions.Logging.ILogger logger = default);
new Microsoft.PowerPlatform.Dataverse.Client.ServiceClient : System.Security.Cryptography.X509Certificates.X509Certificate2 * System.Security.Cryptography.X509Certificates.StoreName * string * Uri * string * bool * bool * Microsoft.Xrm.Sdk.Discovery.OrganizationDetail * string * Uri * Microsoft.Extensions.Logging.ILogger -> Microsoft.PowerPlatform.Dataverse.Client.ServiceClient
Public Sub New (certificate As X509Certificate2, certificateStoreName As StoreName, certificateThumbPrint As String, instanceUrl As Uri, orgName As String, useSsl As Boolean, useUniqueInstance As Boolean, orgDetail As OrganizationDetail, clientId As String, redirectUri As Uri, Optional logger As ILogger = Nothing)

Parameters

certificate
X509Certificate2

Certificate to use during login

certificateStoreName
StoreName

StoreName to look in for certificate identified by certificateThumbPrint

certificateThumbPrint
String

ThumbPrint of the Certificate to load

instanceUrl
Uri

URL of the Dataverse instance to connect too

orgName
String

Organization name for the Dataverse Instance.

useSsl
Boolean

if true, https:// used

useUniqueInstance
Boolean

if set, will force the system to create a unique connection

orgDetail
OrganizationDetail

Dataverse Org Detail object, this is is returned from a query to the Dataverse Discovery Server service. not required.

clientId
String

The registered client Id on Azure portal.

redirectUri
Uri

The redirect URI application will be redirected post OAuth authentication.

logger
ILogger

Logging provider ILogger

Applies to

ServiceClient(String, SecureString, Uri, Boolean, String, Uri, PromptBehavior, Boolean, String, ILogger)

Log in with OAuth for online connections,

Will attempt to connect directly to the URL provided for the API endpoint.

public ServiceClient (string userId, System.Security.SecureString password, Uri hostUri, bool useUniqueInstance, string clientId, Uri redirectUri, Microsoft.PowerPlatform.Dataverse.Client.Auth.PromptBehavior promptBehavior = Microsoft.PowerPlatform.Dataverse.Client.Auth.PromptBehavior.Auto, bool useDefaultCreds = false, string tokenCacheStorePath = default, Microsoft.Extensions.Logging.ILogger logger = default);
new Microsoft.PowerPlatform.Dataverse.Client.ServiceClient : string * System.Security.SecureString * Uri * bool * string * Uri * Microsoft.PowerPlatform.Dataverse.Client.Auth.PromptBehavior * bool * string * Microsoft.Extensions.Logging.ILogger -> Microsoft.PowerPlatform.Dataverse.Client.ServiceClient
Public Sub New (userId As String, password As SecureString, hostUri As Uri, useUniqueInstance As Boolean, clientId As String, redirectUri As Uri, Optional promptBehavior As PromptBehavior = Microsoft.PowerPlatform.Dataverse.Client.Auth.PromptBehavior.Auto, Optional useDefaultCreds As Boolean = false, Optional tokenCacheStorePath As String = Nothing, Optional logger As ILogger = Nothing)

Parameters

userId
String

User Id supplied

password
SecureString

Password for login

hostUri
Uri

API or Instance URI to access the Dataverse environment.

useUniqueInstance
Boolean

if set, will force the system to create a unique connection

clientId
String

The registered client Id on Azure portal.

redirectUri
Uri

The redirect URI application will be redirected post OAuth authentication.

promptBehavior
PromptBehavior

The prompt Behavior.

useDefaultCreds
Boolean

(optional) If true attempts login using current user ( Online )

tokenCacheStorePath
String

(Optional)The token cache path where token cache file is placed. if string.empty, will use default cache file store, if null, will use in memory cache

logger
ILogger

Logging provider ILogger

Remarks

The ServiceClient will attempt to connect directly to the URL provided for the API endpoint.

Applies to

ServiceClient(String, ILogger)

ServiceClient to accept the connectionstring as a parameter

public ServiceClient (string dataverseConnectionString, Microsoft.Extensions.Logging.ILogger logger = default);
new Microsoft.PowerPlatform.Dataverse.Client.ServiceClient : string * Microsoft.Extensions.Logging.ILogger -> Microsoft.PowerPlatform.Dataverse.Client.ServiceClient
Public Sub New (dataverseConnectionString As String, Optional logger As ILogger = Nothing)

Parameters

dataverseConnectionString
String
logger
ILogger

Logging provider ILogger

Remarks

More information: Connection string parameters

Applies to

ServiceClient(Uri, String, String, Boolean, ILogger)

ClientID \ ClientSecret Based Authentication flow.

public ServiceClient (Uri instanceUrl, string clientId, string clientSecret, bool useUniqueInstance, Microsoft.Extensions.Logging.ILogger logger = default);
new Microsoft.PowerPlatform.Dataverse.Client.ServiceClient : Uri * string * string * bool * Microsoft.Extensions.Logging.ILogger -> Microsoft.PowerPlatform.Dataverse.Client.ServiceClient
Public Sub New (instanceUrl As Uri, clientId As String, clientSecret As String, useUniqueInstance As Boolean, Optional logger As ILogger = Nothing)

Parameters

instanceUrl
Uri

Direct URL of Dataverse instance to connect too.

clientId
String

The registered client Id on Azure portal.

clientSecret
String

Client Secret for Client Id.

useUniqueInstance
Boolean

Use unique instance or reuse current connection.

logger
ILogger

Logging provider ILogger

Applies to

ServiceClient(Uri, String, SecureString, Boolean, ILogger)

ClientID \ ClientSecret Based Authentication flow, allowing for Secure Client ID passing.

public ServiceClient (Uri instanceUrl, string clientId, System.Security.SecureString clientSecret, bool useUniqueInstance, Microsoft.Extensions.Logging.ILogger logger = default);
new Microsoft.PowerPlatform.Dataverse.Client.ServiceClient : Uri * string * System.Security.SecureString * bool * Microsoft.Extensions.Logging.ILogger -> Microsoft.PowerPlatform.Dataverse.Client.ServiceClient
Public Sub New (instanceUrl As Uri, clientId As String, clientSecret As SecureString, useUniqueInstance As Boolean, Optional logger As ILogger = Nothing)

Parameters

instanceUrl
Uri

Direct URL of Dataverse instance to connect too.

clientId
String

The registered client Id on Azure portal.

clientSecret
SecureString

Client Secret for Client Id.

useUniqueInstance
Boolean

Use unique instance or reuse current connection.

logger
ILogger

Logging provider ILogger

Applies to

ServiceClient(Uri, Func<String,Task<String>>, Boolean, ILogger)

Creates an instance of ServiceClient who's authentication is managed by the caller. This requires the caller to implement a function that will accept the InstanceURI as a string will return the access token as a string on demand when the ServiceClient requires it. This approach is recommended when working with WebApplications or applications that are required to implement an on Behalf of flow for user authentication.

public ServiceClient (Uri instanceUrl, Func<string,System.Threading.Tasks.Task<string>> tokenProviderFunction, bool useUniqueInstance = true, Microsoft.Extensions.Logging.ILogger logger = default);
new Microsoft.PowerPlatform.Dataverse.Client.ServiceClient : Uri * Func<string, System.Threading.Tasks.Task<string>> * bool * Microsoft.Extensions.Logging.ILogger -> Microsoft.PowerPlatform.Dataverse.Client.ServiceClient
Public Sub New (instanceUrl As Uri, tokenProviderFunction As Func(Of String, Task(Of String)), Optional useUniqueInstance As Boolean = true, Optional logger As ILogger = Nothing)

Parameters

instanceUrl
Uri

URL of the Dataverse instance to connect too.

tokenProviderFunction
Func<String,Task<String>>

Function that will be called when the access token is require for interaction with Dataverse. This function must accept a string (InstanceURI) and return a string (accesstoken)

useUniqueInstance
Boolean

A value of "true" Forces the ServiceClient to create a new connection to the Dataverse instance vs reusing an existing connection, Defaults to true.

logger
ILogger

Logging provider ILogger

Remarks

Creates an instance of ServiceClient where authentication is managed by the caller. This requires the caller to implement a function that will accept the InstanceURI as a string and will return the access token as a string on demand when the ServiceClient requires it. This approach is recommended when working with WebApplications or applications that are required to implement an On-Behalf-Of flow for user authentication.

Applies to

ServiceClient(ConnectionOptions, Boolean, ConfigurationOptions)

Creating the ServiceClient Connection with a ConnectionOptions Object and ConfigurationOptions Object. This allows for deferred create of a Dataverse Service Client.

public ServiceClient (Microsoft.PowerPlatform.Dataverse.Client.Model.ConnectionOptions connectionOptions, bool deferConnection = false, Microsoft.PowerPlatform.Dataverse.Client.Model.ConfigurationOptions serviceClientConfiguration = default);
new Microsoft.PowerPlatform.Dataverse.Client.ServiceClient : Microsoft.PowerPlatform.Dataverse.Client.Model.ConnectionOptions * bool * Microsoft.PowerPlatform.Dataverse.Client.Model.ConfigurationOptions -> Microsoft.PowerPlatform.Dataverse.Client.ServiceClient
Public Sub New (connectionOptions As ConnectionOptions, Optional deferConnection As Boolean = false, Optional serviceClientConfiguration As ConfigurationOptions = Nothing)

Parameters

connectionOptions
ConnectionOptions

Describes how the Connection should be created.

deferConnection
Boolean

False by Default, if True, stages the properties of the connection and returns. You must call .Connect() to complete the connection.

serviceClientConfiguration
ConfigurationOptions

Described Configuration Options for the connection.

Remarks

Creates a ServiceClient connection with a ConnectionOptions object and ConfigurationOptions object. This allows for deferred creation of a Dataverse ServiceClient.

Applies to

ServiceClient(X509Certificate2, StoreName, String, Uri, Boolean, OrganizationDetail, String, Uri, ILogger)

Log in with Certificate Auth OnLine connections. This requires the org API URI.

public ServiceClient (System.Security.Cryptography.X509Certificates.X509Certificate2 certificate, System.Security.Cryptography.X509Certificates.StoreName certificateStoreName, string certificateThumbPrint, Uri instanceUrl, bool useUniqueInstance, Microsoft.Xrm.Sdk.Discovery.OrganizationDetail orgDetail, string clientId, Uri redirectUri, Microsoft.Extensions.Logging.ILogger logger = default);
new Microsoft.PowerPlatform.Dataverse.Client.ServiceClient : System.Security.Cryptography.X509Certificates.X509Certificate2 * System.Security.Cryptography.X509Certificates.StoreName * string * Uri * bool * Microsoft.Xrm.Sdk.Discovery.OrganizationDetail * string * Uri * Microsoft.Extensions.Logging.ILogger -> Microsoft.PowerPlatform.Dataverse.Client.ServiceClient
Public Sub New (certificate As X509Certificate2, certificateStoreName As StoreName, certificateThumbPrint As String, instanceUrl As Uri, useUniqueInstance As Boolean, orgDetail As OrganizationDetail, clientId As String, redirectUri As Uri, Optional logger As ILogger = Nothing)

Parameters

certificate
X509Certificate2

Certificate to use during login

certificateStoreName
StoreName

StoreName to look in for certificate identified by certificateThumbPrint

certificateThumbPrint
String

ThumbPrint of the Certificate to load

instanceUrl
Uri

API URL of the Dataverse instance to connect too

useUniqueInstance
Boolean

if set, will force the system to create a unique connection

orgDetail
OrganizationDetail

Dataverse Org Detail object, this is is returned from a query to the Dataverse Discovery Server service. not required.

clientId
String

The registered client Id on Azure portal.

redirectUri
Uri

The redirect URI application will be redirected post OAuth authentication.

logger
ILogger

Logging provider ILogger

Applies to