github.com/huaweicloud/golangsdk@v0.0.0-20210831081626-d823fe11ceba/openstack/identity/v3/tokens/doc.go (about) 1 /* 2 Package tokens provides information and interaction with the token API 3 resource for the OpenStack Identity service. 4 5 For more information, see: 6 http://developer.openstack.org/api-ref-identity-v3.html#tokens-v3 7 8 Example to Create a Token From a Username and Password 9 10 authOptions := tokens.AuthOptions{ 11 UserID: "username", 12 Password: "password", 13 } 14 15 token, err := tokens.Create(identityClient, authOptions).ExtractToken() 16 if err != nil { 17 panic(err) 18 } 19 20 Example to Create a Token From a Username, Password, and Domain 21 22 authOptions := tokens.AuthOptions{ 23 UserID: "username", 24 Password: "password", 25 DomainID: "default", 26 } 27 28 token, err := tokens.Create(identityClient, authOptions).ExtractToken() 29 if err != nil { 30 panic(err) 31 } 32 33 authOptions = tokens.AuthOptions{ 34 UserID: "username", 35 Password: "password", 36 DomainName: "default", 37 } 38 39 token, err = tokens.Create(identityClient, authOptions).ExtractToken() 40 if err != nil { 41 panic(err) 42 } 43 44 Example to Create a Token From a Token 45 46 authOptions := tokens.AuthOptions{ 47 TokenID: "token_id", 48 } 49 50 token, err := tokens.Create(identityClient, authOptions).ExtractToken() 51 if err != nil { 52 panic(err) 53 } 54 55 Example to Create a Token from a Username and Password with Project ID Scope 56 57 scope := tokens.Scope{ 58 ProjectID: "0fe36e73809d46aeae6705c39077b1b3", 59 } 60 61 authOptions := tokens.AuthOptions{ 62 Scope: &scope, 63 UserID: "username", 64 Password: "password", 65 } 66 67 token, err = tokens.Create(identityClient, authOptions).ExtractToken() 68 if err != nil { 69 panic(err) 70 } 71 72 Example to Create a Token from a Username and Password with Domain ID Scope 73 74 scope := tokens.Scope{ 75 DomainID: "default", 76 } 77 78 authOptions := tokens.AuthOptions{ 79 Scope: &scope, 80 UserID: "username", 81 Password: "password", 82 } 83 84 token, err = tokens.Create(identityClient, authOptions).ExtractToken() 85 if err != nil { 86 panic(err) 87 } 88 89 Example to Create a Token from a Username and Password with Project Name Scope 90 91 scope := tokens.Scope{ 92 ProjectName: "project_name", 93 DomainID: "default", 94 } 95 96 authOptions := tokens.AuthOptions{ 97 Scope: &scope, 98 UserID: "username", 99 Password: "password", 100 } 101 102 token, err = tokens.Create(identityClient, authOptions).ExtractToken() 103 if err != nil { 104 panic(err) 105 } 106 107 */ 108 package tokens