github.com/chnsz/golangsdk@v0.0.0-20240506093406-85a3fbfa605b/openstack/meeting/v2/auth/requests.go (about)

     1  package auth
     2  
     3  import (
     4  	"github.com/chnsz/golangsdk"
     5  )
     6  
     7  type AuthOpts struct {
     8  	// Application ID.
     9  	AppId string `json:"appId" required:"true"`
    10  	// Login account type.
    11  	//   72: API call type.
    12  	ClientType int `json:"clientType" required:"true"`
    13  	// Application authentication information expiration timestamp, in seconds.
    14  	// When the Unix timestamp of the server is greater than expireTime when the app authentication request is received,
    15  	// the authentication fails. Example: If the application authentication information is required to expire after 10
    16  	// minutes, expireTime = current Unix timestamp + 60*10; if The application authentication information is required
    17  	// to never expire, expireTime = 0)
    18  	ExpireTime *int `json:"expireTime" required:"true"`
    19  	// A random string used to calculate application authentication information.
    20  	// The maxLength: 64
    21  	// The minLength: 32
    22  	Nonce string `json:"nonce" required:"true"`
    23  	// Enterprise ID. (When the SP application scenario is carried, if the corpId and userId fields are not carried or
    24  	// the value is an empty string, log in as the SP default administrator)
    25  	CorpId string `json:"corpId,omitempty"`
    26  	// User ID. (When the userId field is not carried or the value is an empty string, log in as the enterprise default
    27  	// administrator)
    28  	UserId string `json:"userId,omitempty"`
    29  	// User email.
    30  	UserEmail string `json:"userEmail,omitempty"`
    31  	// User name.
    32  	UserName string `json:"userName,omitempty"`
    33  	// User phone.
    34  	UserPhone string `json:"userPhone,omitempty"`
    35  	// Department code.
    36  	DeptCode string `json:"deptCode,omitempty"`
    37  }
    38  
    39  // GetToken is a method to to generate a token using application information.
    40  func GetToken(c *golangsdk.ServiceClient, opts AuthOpts, authorization string) (*AuthResp, error) {
    41  	b, err := golangsdk.BuildRequestBody(opts, "")
    42  	if err != nil {
    43  		return nil, err
    44  	}
    45  
    46  	var r AuthResp
    47  	_, err = c.Post(rootURL(c), b, &r, &golangsdk.RequestOpts{
    48  		MoreHeaders: map[string]string{
    49  			"Content-Type":  "application/json;charset=UTF-8",
    50  			"Authorization": authorization,
    51  		},
    52  	})
    53  	return &r, err
    54  }