doc.go 2.2 KB

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