// Used to refresh OAuth2 access_token
Used to refresh OAuth2 access_token
// Used to refresh OAuth2 access_token
func (conn *Connection) Refresh() (err error) {
	urlValues := url.Values{}
	urlValues.Set("grant_type", "password")
	urlValues.Set("client_id", conn.ConsumerKey)
	urlValues.Set("client_secret", conn.ConsumerSecret)
	urlValues.Set("username", conn.Username)
	urlValues.Set("password", conn.Password)
	resp, err := http.PostForm(conn.InstanceUrl+"/services/oauth2/token", urlValues)
	if err != nil {
		return err
	}
	body, err := ioutil.ReadAll(resp.Body)
	defer resp.Body.Close()
	if err != nil {
		return err
	}
	result := OAuthResponse{}
	err = json.Unmarshal(body, &result)
	if err != nil {
		return err
	}
	conn.AccessToken = result.AccessToken
	conn.InstanceUrl = result.InstanceUrl
	return nil
}
func ( conn * Connection ) Refresh ( ) ( err error ) { urlValues := url . Values { } urlValues . Set ( " " , " " ) urlValues . Set ( " " , conn . ConsumerKey ) urlValues . Set ( " " , conn . ConsumerSecret ) urlValues . Set ( " " , conn . Username ) urlValues . Set ( " " , conn . Password ) resp , err := http . PostForm ( conn . InstanceUrl + " " , urlValues ) if err != nil { return err } body , err := ioutil . ReadAll ( resp . Body ) defer resp . Body . Close ( ) if err != nil { return err } result := OAuthResponse { } err = json . Unmarshal ( body , & result ) if err != nil { return err } conn . AccessToken = result . AccessToken conn . InstanceUrl = result . InstanceUrl return nil }
Used to refresh OAuth2 access_token
Used to refresh OAuth2 access_token