1
0
mirror of https://github.com/Unleash/unleash.git synced 2024-10-18 20:09:08 +02:00
unleash.unleash/docs/user_guide/connect-sdk.md
Alexis Degrugillier 0f60fd075a
chore: Fix documentation typos (#758)
Co-authored-by: Alexis Degrugillier <alexis.degrugillier@duproprio.com>
2021-03-09 21:44:45 +01:00

4.3 KiB
Raw Blame History

id title
connect_sdk Connect your SDK

In order to connect your application to Unleash you need to use a client SDK (software developer kit) for your programming language. The SDK will handle connecting to the Unleash server instance and retrieve feature toggles based upon your configuration. Both open-source and the Unleash enterprise offering utilize the same set of client SDKs.

If you are an Unleash customer, our hosted instances will always be a protected instance, you will therefore have to specify a client secret as the authorization header when you are connecting your client SDK, which you will receive from us when you sign up for one of our packages. In the open source version you must generate your own secret.

On this page you will find examples for connecting your application to the demo instance. If you are connecting to your own private instance you will have to remember to replace the client secret and the API url given in the examples.

We have examples for all official client SDKs:

When you get access to your instance we will provide you with your Client secret and your API url for your instance.

Demo instance secrets

Our demo instance has the following settings use these in case you would like to connect your test-app to our demo environment.

Client secret

56907a2fa53c1d16101d509a10b78e36190b0f918d9f122d

API url:

https://app.unleash-hosted.com/demo/api/

Test with curl:

curl https://app.unleash-hosted.com/demo/api/client/features \     
-H "Authorization: 56907a2fa53c1d16101d509a10b78e36190b0f918d9f122d";

Java SDK

UnleashConfig unleashConfig = UnleashConfig.builder()
        .appName("my.java-app")
        .instanceId("your-instance-1")
        .unleashAPI("<API url>")
        .customHttpHeader("Authorization", "<client secret>")
        .build();

    Unleash unleash = new DefaultUnleash(config);

Read more at github.com/Unleash/unleash-client-java

Node.js SDK

const unleash = require('unleash-client');
    
unleash.initialize({
  url: '<API url>',
  appName: 'my-node-name',
  instanceId: 'my-unique-instance-id',
  customHeaders: {'Authorization': '<Client secret>'}
});

Read more at github.com/Unleash/unleash-client-node

Go SDK

import (
  "github.com/Unleash/unleash-client-go/v3"
)

func init() {
  unleash.Initialize(
    unleash.WithAppName("my-node-app"),
    unleash.WithUrl("<API url>"),
    unleash.WithCustomHeaders(http.Header{"Authorization": {"<Client secret>"}}),
  )
}

Read more at github.com/Unleash/unleash-client-go

Ruby SDK



    require 'unleash'
  
    @unleash = Unleash::Client.new(
      url: '<API url>',
      app_name: 'simple-test',
      custom_http_headers = {'Authorization': '<Client secret>'},
    )

Read more at github.com/Unleash/unleash-client-ruby

Python SDK


    from UnleashClient import UnleashClient
  
    client = UnleashClient(
        url="<API url>",
        app_name="my-python-app",
        custom_headers={'Authorization': '<Client secret>'})
    
    client.initialize_client()
  
    client.is_enabled("unleash.beta.variants")

Read more at github.com/Unleash/unleash-client-python

.NET SDK

    var settings = new UnleashSettings()
    {
        AppName = "dotnet-test",
        InstanceTag = "instance z",
        UnleashApi = new Uri("<API url>"),
        SendMetricsInterval = TimeSpan.FromSeconds(20),
        CustomHttpHeaders = new Dictionary<string, string>()
        {
            {"Authorization","<Client secret>" }
        }
    };
  
    var unleash = new DefaultUnleash(settings);

Read more at https://github.com/Unleash/unleash-client-dotnet