1. Help Center
  2. CLI
  3. Developer Guide
  4. SDK
  5. Go
  6. IAM Go SDK User Guide

IAM Go SDK User Guide

Service Client

To interact with OpenStack APIs, transfer the identity credentials to the provider. After that, if you want to retrieve any information about the identity service, you need to make a call to NewIdentityV3 to create an identity service client and then use required SDKs.

client, err := openstack.NewIdentityV3(provider, gophercloud.EndpointOpts{
 Region: "RegionName",


A token is a text returned during authentication. It is used for subsequent access and control of API resources. Each token has a specific range, which specifies the resources that can be accessed using the token.

Create a token.

import (    "github.com/gophercloud/gophercloud/openstack/identity/v3/tokens"   )   

func TestCreateTokenByPasswd(t *testing.T){
    scope := tokens.Scope{
        ProjectName:  TenantName,
        DomainID:     DomainID,

    authOptions := tokens.AuthOptions{
           Username:   Username,
           Password:   Password,
        DomainName: DomainName,
        Scope:      scope,

    token, err := tokens.Create(client, &authOptions).Extract()

Validate a token.

Check whether the token is valid.

func TestValidateToken(t *testing.T) {
    token, err := tokens.Validate(client, "token_id")

Service Catalogs

A service is a RESTful API that controls an OpenStack service function. The controlled OpenStack services include the compute and object storage services. A service provides one or multiple endpoints. Through these endpoints, you can access resources and perform required operations.

List services.

import (    "github.com/gophercloud/gophercloud/openstack/identity/v3/services"   )     

func TestServicesList(t *testing.T) {
// List enumerates the services available to a specific user.
listOpts := services.ListOpts{
           ServiceType: "identity",
// Retrieve a pager (i.e. a paginated collection)
allPages, err := services.List(client, listOpts).AllPages()

// Define an anonymous function to be executed on each page's iteration
allServices, err := services.ExtractServices(allPages)

for _, service := range allServices {
    // " service " will be a services.Service

Get details about a specific service.

func TestServicesGet(t *testing.T) {
    service, err := services.Get(client,"service_id").Extract()


An endpoint is a network accessible address. Generally, it is a URL address used to access a service.

List endpoints.

import (    "github.com/gophercloud/gophercloud/openstack/identity/v3/endpoints"   ) 

func TestEndpointsList(t *testing.T) {
    endpointListOpts := endpoints.ListOpts{
           Availability: gophercloud.AvailabilityPublic,
// Retrieve a pager (i.e. a paginated collection)
    allPages, err := endpoints.List(client, endpointListOpts).AllPages()

    // Define an anonymous function to be executed on each page's iteration
allEndpoints, err := endpoints.ExtractEndpoints(allPages)

    for _, endpoint := range allEndpoints {
        // "endpoint " will be a endpoints.Endpoint