func Login(c *http.Client, user string, pass string) (Credentials, error) {
	data := url.Values{
		"grant_type": {"password"},
		"password":   {pass},
		"scope":      {"account content offline_access"},
		"username":   {user},
	}
	reader := strings.NewReader(data.Encode())
	req, err := http.NewRequest(http.MethodPost, "https://beta-api.crunchyroll.com/auth/v1/token", reader)
	authString := base64.StdEncoding.EncodeToString([]byte(common.ClientID + ":" + common.ClientSecret))

	if err != nil {
		return Credentials{}, err
	}

	req.Header.Add("User-Agent", common.UserAgent)
	req.Header.Add("Authorization", "Basic "+authString)
	req.Header.Add("Content-Type", "application/x-www-form-urlencoded; charset=utf-8")
	req.Header.Add("Accept-Language", "en-US;q=1.0")

	resp, err := c.Do(req)

	if err != nil {
		return Credentials{}, err
	}

	defer resp.Body.Close()

	var credientials Credentials
	body, _ := ioutil.ReadAll(resp.Body)
	json.Unmarshal([]byte(body), &credientials)

	return credientials, nil
}
// Login creates a new crunchyroll session
Login creates a new crunchyroll session
// Login creates a new crunchyroll session
func Login(c *http.Client, user string, pass string) (Credentials, error) {
	data := url.Values{
		"grant_type": {"password"},
		"password":   {pass},
		"scope":      {"account content offline_access"},
		"username":   {user},
	}
	reader := strings.NewReader(data.Encode())
	req, err := http.NewRequest(http.MethodPost, "https://beta-api.crunchyroll.com/auth/v1/token", reader)
	authString := base64.StdEncoding.EncodeToString([]byte(common.ClientID + ":" + common.ClientSecret))
	if err != nil {
		return Credentials{}, err
	}
	req.Header.Add("User-Agent", common.UserAgent)
	req.Header.Add("Authorization", "Basic "+authString)
	req.Header.Add("Content-Type", "application/x-www-form-urlencoded; charset=utf-8")
	req.Header.Add("Accept-Language", "en-US;q=1.0")
	resp, err := c.Do(req)
	if err != nil {
		return Credentials{}, err
	}
	defer resp.Body.Close()
	var credientials Credentials
	body, _ := ioutil.ReadAll(resp.Body)
	json.Unmarshal([]byte(body), &credientials)
	return credientials, nil
}
func Login ( c * http . Client , user string , pass string ) ( Credentials , error ) { data := url . Values { " " : { " " } , " " : { pass } , " " : { " " } , " " : { user } , } reader := strings . NewReader ( data . Encode ( ) ) req , err := http . NewRequest ( http . MethodPost , " " , reader ) authString := base64 . StdEncoding . EncodeToString ( [ ] byte ( common . ClientID + " " + common . ClientSecret ) ) if err != nil { return Credentials { } , err } req . Header . Add ( " " , common . UserAgent ) req . Header . Add ( " " , " " + authString ) req . Header . Add ( " " , " " ) req . Header . Add ( " " , " " ) resp , err := c . Do ( req ) if err != nil { return Credentials { } , err } defer resp . Body . Close ( ) var credientials Credentials body , _ := ioutil . ReadAll ( resp . Body ) json . Unmarshal ( [ ] byte ( body ) , & credientials ) return credientials , nil }
Login creates a new crunchyroll session
Login creates a new crunchyroll session