eyetowers / gonvif

Onvif Go client library and CLI tool.
MIT License
9 stars 3 forks source link

Retrieve profile token #5

Closed jsalatiel closed 2 months ago

jsalatiel commented 2 months ago

Hello! Is there any command to return the profile token required by several commands ? ( like get-presets for example )

If I try onvif media get-profiles I can see several profiles, but none of the keys that have "token" as substring work as token,

Kerblif commented 2 months ago

GetProfiles operation returns array of profiles.

Here is response of this operation:

type GetProfilesResponse struct {
    XMLName xml.Name `xml:"http://www.onvif.org/ver10/media/wsdl GetProfilesResponse" json:"-"`

    // lists all profiles that exist in the media service
    Profiles []*tt.Profile `xml:"Profiles,omitempty" json:"Profiles,omitempty"`
}

And tt.Profile (which is also known as shema.Profile) has Token field. Token has *ReferenceToken type. If you want to get it as string, you can do fmt.Sprintf("%s", *token ).

But if you use only this package, then you should not transfer the token to a string, since in subsequent calls it is the *ReferenceToken that is required.

osery commented 2 months ago

Thanks for answering this question. Closing the issue.