-
Notifications
You must be signed in to change notification settings - Fork 101
Connect and Authenticate
Carolyn Van Slyck edited this page Jan 4, 2016
·
1 revision
Below is an example of how to connect and authenticate to any OpenStack provider. At the moment we only support identity v2, so make sure to use the right endpoint.
Install the openstack.net NuGet package.
Below is a .NET Console Application. Replace {user-name}
, {password}
, {project-name}
and {identity-url}
with your credentials.
using System;
using net.openstack.Core.Domain;
using net.openstack.Core.Providers;
using net.openstack.Providers.Rackspace;
namespace MyApplication
{
class Program
{
static void Main(string[] args)
{
var identityEndpoint = new Uri("{identity-url}");
var identity = new CloudIdentityWithProject
{
Username = "{user-name}",
Password = "{password}",
ProjectName = "{project-name}"
};
var identityProvider = new OpenStackIdentityProvider(identityEndpoint, identity);
// Verify that we can connect and our credentials are correct
identityProvider.Authenticate();
// Now that we know we can connect, use the identity with another service
var serverProvider = new CloudServersProvider(identity);
serverProvider.ListFlavors();
}
}
}