// GetTokenFromPinRequest takes in a PinRequest and checks if it has been authenticated.
// If it has been authenticated it returns the token.
// If it has not been authenticated it returns an empty string.
GetTokenFromPinRequest takes in a PinRequest and checks if it has been authenticated.
If it has been authenticated it returns the token.
If it has not been authenticated it returns an empty string.
// GetTokenFromPinRequest takes in a PinRequest and checks if it has been authenticated . // If it has been authenticated it returns the token . // If it has not been authenticated it returns an empty string .
func GetTokenFromPinRequest(p *PinRequest) (string, error) {
	httpClient := &http.Client{Timeout: time.Second * 10}
	_, body, err := sendRequest("GET", fmt.Sprintf("https://plex.tv/pins/%d", p.Id), headers, httpClient)
	if err != nil {
		return "", err
	}
	pinRequest := PinRequest{}
	err = json.Unmarshal(body, &pinRequest)
	if err != nil {
		return "", err
	}
	if pinRequest.AuthToken == "" {
		return "", fmt.Errorf(ErrorPinNotAuthorized)
	}
	return pinRequest.AuthToken, nil
}
func GetTokenFromPinRequest ( p * PinRequest ) ( string , error ) { httpClient := & http . Client { Timeout : time . Second * 10 } _ , body , err := sendRequest ( " " , fmt . Sprintf ( " " , p . Id ) , headers , httpClient ) if err != nil { return " " , err } pinRequest := PinRequest { } err = json . Unmarshal ( body , & pinRequest ) if err != nil { return " " , err } if pinRequest . AuthToken == " " { return " " , fmt . Errorf ( ErrorPinNotAuthorized ) } return pinRequest . AuthToken , nil }
GetTokenFromPinRequest takes in a PinRequest and checks if it has been authenticated.
GetTokenFromPinRequest takes in a PinRequest and checks if it has been authenticated .