Back to Devexpress

UriJsonSource.AuthenticationInfo Property

corelibraries-devexpress-dot-dataaccess-dot-json-dot-urijsonsource-6dbccd2f.md

latest4.7 KB
Original Source

UriJsonSource.AuthenticationInfo Property

Specifies the Basic authentication parameters that the associated web service endpoint requests.

Namespace : DevExpress.DataAccess.Json

Assembly : DevExpress.DataAccess.v25.2.dll

NuGet Package : DevExpress.DataAccess

Declaration

csharp
[Browsable(false)]
public HttpBasicAuthenticationInfo AuthenticationInfo { get; }
vb
<Browsable(False)>
Public ReadOnly Property AuthenticationInfo As HttpBasicAuthenticationInfo

Property Value

TypeDescription
HttpBasicAuthenticationInfo

An object that specifies the Username and Password parameters.

|

Remarks

Use this property to provide authentication credentials to a JSON web service endpoint. Set this property to a HttpBasicAuthenticationInfo object and specify this object’s Username and Password properties.

csharp
public static JsonDataSource CreateReportDataSourceWithAuthenticationInCode() {
// ...
    // Create a new UriJsonSource object and configure authentication data in it
    var jsonSource = new DevExpress.DataAccess.Json.UriJsonSource();
    jsonSource.Uri = new Uri(@"http://northwind.servicestack.net/customers.json");

    jsonSource.AuthenticationInfo.Username = "user";
    jsonSource.AuthenticationInfo.Password = "pwd";

    jsonSource.HeaderParameters.Add(new HeaderParameter("MyAuthHeader1", "secretToken1"));
    jsonSource.HeaderParameters.Add(new HeaderParameter("MyAuthHeader2", "secretToken2"));

    jsonSource.QueryParameters.Add(new QueryParameter("id", "123456"));
    jsonSource.QueryParameters.Add(new QueryParameter("name", "MyName"));
    // ...
    // Create a JsonDataSource object and assign the UriJsonSource object to it
    var jsonDataSource = new DevExpress.DataAccess.Json.JsonDataSource() {
        JsonSource = jsonSource
    };

    return jsonDataSource;
vb
Public Shared Function CreateReportDataSourceWithAuthenticationInCode() As JsonDataSource
' ...
            ' Create a new UriJsonSource object and configure authentication data in it
            Dim jsonSource = New DevExpress.DataAccess.Json.UriJsonSource()
            jsonSource.Uri = New Uri("http://northwind.servicestack.net/customers.json")

            jsonSource.AuthenticationInfo.Username = "user"
            jsonSource.AuthenticationInfo.Password = "pwd"

            jsonSource.HeaderParameters.Add(New HeaderParameter("MyAuthHeader1", "secretToken1"))
            jsonSource.HeaderParameters.Add(New HeaderParameter("MyAuthHeader2", "secretToken2"))

            jsonSource.QueryParameters.Add(New QueryParameter("id", "123456"))
            jsonSource.QueryParameters.Add(New QueryParameter("name", "MyName"))
' ...
            ' Create a JsonDataSource object and assign the UriJsonSource object to it
            Dim jsonDataSource = New DevExpress.DataAccess.Json.JsonDataSource() With {.JsonSource = jsonSource}

            Return jsonDataSource

View Example: How to Provide Authentication to Access Json Data in Reports

You can also specify authentication parameters in the application’s connection string and assign the connection name to the JsonDataSource ‘s ConnectionName property.

Refer to the Provide Authentication to Access JSON Data (Runtime Sample) topic for information on how to provide a report‘s JSON data source with authentication parameters at runtime.

See Also

HeaderParameters

QueryParameters

ConnectionName

UriJsonSource Class

UriJsonSource Members

DevExpress.DataAccess.Json Namespace