---
title: "Class MClientFactory"
slug: "web-sdk--stylelabs.m.sdk.webclient.mclientfactory"
abstract: ""
---
# Class MClientFactory

Defines the M client factory.

## Inheritance

object

MClientFactory

## Namespace: StylelabsStylelabs.MSdkWebClient

## Assembly: Stylelabs.M.Sdk.WebClient.dll

## Syntax

```csharp
public static class MClientFactory
```

## Methods

### CreateMClient(string)

Creates a new instance of the [IWebMClient](https://doc.sitecore.com/ch/en/developers/api-reference/web-sdk--stylelabs.m.sdk.webclient.iwebmclient.html) implementation.

#### Declaration

```csharp
public static IWebMClient CreateMClient(string connectionString)
```

#### Parameters

| Type | Name | Description |
| --- | --- | --- |
| string | connectionString | Connection string to the instance. |

#### Returns

| Type | Description |
| --- | --- |
| [IWebMClient](https://doc.sitecore.com/ch/en/developers/api-reference/web-sdk--stylelabs.m.sdk.webclient.iwebmclient.html) | A new [IWebMClient](https://doc.sitecore.com/ch/en/developers/api-reference/web-sdk--stylelabs.m.sdk.webclient.iwebmclient.html) instance. |

## Examples

This example shows how to create a [IWebMClient](https://doc.sitecore.com/ch/en/developers/api-reference/web-sdk--stylelabs.m.sdk.webclient.iwebmclient.html) instance using the [OAuthPasswordGrant](https://doc.sitecore.com/ch/en/developers/api-reference/web-sdk--stylelabs.m.sdk.webclient.authentication.oauthpasswordgrant.html).

```csharp
MClientFactory.CreateMClient("Endpoint=http://url/;ClientId=clientId;ClientSecret=clientSecret;UserName=userName;Password=password");
```

This example shows how to create a [IWebMClient](https://doc.sitecore.com/ch/en/developers/api-reference/web-sdk--stylelabs.m.sdk.webclient.iwebmclient.html) instance using the [OAuthRefreshTokenGrant](https://doc.sitecore.com/ch/en/developers/api-reference/web-sdk--stylelabs.m.sdk.webclient.authentication.oauthrefreshtokengrant.html).

```csharp
MClientFactory.CreateMClient("Endpoint=http://url/;ClientId=clientId;ClientSecret=clientSecret;RefreshToken=refreshToken");
```

### CreateMClient(Uri, OAuthPasswordGrant)

Creates a new instance of the [IWebMClient](https://doc.sitecore.com/ch/en/developers/api-reference/web-sdk--stylelabs.m.sdk.webclient.iwebmclient.html) implementation.

#### Declaration

```csharp
public static IWebMClient CreateMClient(Uri endpoint, OAuthPasswordGrant passwordGrant)
```

#### Parameters

| Type | Name | Description |
| --- | --- | --- |
| Uri | endpoint | Base URI of the Sitecore Content Hub instance to connect to. |
| [OAuthPasswordGrant](https://doc.sitecore.com/ch/en/developers/api-reference/web-sdk--stylelabs.m.sdk.webclient.authentication.oauthpasswordgrant.html) | passwordGrant | OAuth authentication details. |

#### Returns

| Type | Description |
| --- | --- |
| [IWebMClient](https://doc.sitecore.com/ch/en/developers/api-reference/web-sdk--stylelabs.m.sdk.webclient.iwebmclient.html) | A new [IWebMClient](https://doc.sitecore.com/ch/en/developers/api-reference/web-sdk--stylelabs.m.sdk.webclient.iwebmclient.html) instance. |

### CreateMClient(Uri, OAuthRefreshTokenGrant)

Creates a new instance of the [IWebMClient](https://doc.sitecore.com/ch/en/developers/api-reference/web-sdk--stylelabs.m.sdk.webclient.iwebmclient.html) implementation.

#### Declaration

```csharp
public static IWebMClient CreateMClient(Uri endpoint, OAuthRefreshTokenGrant refreshTokenGrant)
```

#### Parameters

| Type | Name | Description |
| --- | --- | --- |
| Uri | endpoint | Base uri of the Sitecore Content Hub instance to connect to. |
| [OAuthRefreshTokenGrant](https://doc.sitecore.com/ch/en/developers/api-reference/web-sdk--stylelabs.m.sdk.webclient.authentication.oauthrefreshtokengrant.html) | refreshTokenGrant | OAuth authentication details. |

#### Returns

| Type | Description |
| --- | --- |
| [IWebMClient](https://doc.sitecore.com/ch/en/developers/api-reference/web-sdk--stylelabs.m.sdk.webclient.iwebmclient.html) | A new [IWebMClient](https://doc.sitecore.com/ch/en/developers/api-reference/web-sdk--stylelabs.m.sdk.webclient.iwebmclient.html) instance. |

### CreateMClient(Uri)

Creates a new instance of the [IWebMClient](https://doc.sitecore.com/ch/en/developers/api-reference/web-sdk--stylelabs.m.sdk.webclient.iwebmclient.html) implementation.

#### Declaration

```csharp
public static IWebMClient CreateMClient(Uri endpoint)
```

#### Parameters

| Type | Name | Description |
| --- | --- | --- |
| Uri | endpoint | Base uri of the Sitecore Content Hub instance to connect to. |

#### Returns

| Type | Description |
| --- | --- |
| [IWebMClient](https://doc.sitecore.com/ch/en/developers/api-reference/web-sdk--stylelabs.m.sdk.webclient.iwebmclient.html) | A new [IWebMClient](https://doc.sitecore.com/ch/en/developers/api-reference/web-sdk--stylelabs.m.sdk.webclient.iwebmclient.html) instance. |
