public NdustrialIoApi(string accessToken=null,
            string refreshToken=null,
            string clientID=null,
            string clientSecret=null)
		{
            // Can provide token via argument, environment, or file
            if (accessToken == null)
            {
                Console.WriteLine("Checking environment for token..");

                // Check environment
                accessToken = Environment.GetEnvironmentVariable("ACCESS_TOKEN");

                if (accessToken == null)
                {
                    Console.WriteLine("Checking for token file..");

                    try
                    {
                        JObject tokenObject = JObject.Parse(File.ReadAllText("tokenfile"));

                        accessToken = (String)tokenObject["access_token"];
                        refreshToken = (String)tokenObject["refresh_token"];
                        clientID = (String)tokenObject["client_id"];
                        clientSecret = (String)tokenObject["client_secret"];
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine("Unable to read token data from file, " + e.Message);

                        Environment.Exit(1);
                    }

                } else
                {
                    refreshToken = Environment.GetEnvironmentVariable("REFRESH_TOKEN");
                    clientID = Environment.GetEnvironmentVariable("CLIENT_ID");
                    clientSecret = Environment.GetEnvironmentVariable("CLIENT_SECRET");
                }
            }

            // Instantiate client.  Service objects will share this. 
            _client = new Client(accessToken, refreshToken, clientID, clientSecret);


			_feedService = new Feeds(_client);
            _oauthService = new Oauth(_client);
            _nGestService = new Ngest(_client);
		}
示例#2
0
 public Oauth(Client client) : base(client) { }
示例#3
0
 public Ngest(Client client) : base(client) { }
示例#4
0
		public Feeds(Client client) : base(client) { }