oauth.go
func (o OAuth) GetTokens(code string, grantType string) (*oauthTokens, error) {

	postVars := map[string]string{
		"grant_type":    grantType,
		"redirect_uri":  o.RedirectUri,
		"client_id":     o.ClientId,
		"client_secret": o.ClientSecret,
	}

	if grantType == "refresh_token" {
		postVars["refresh_token"] = code
	} else {
		postVars["code"] = code
	}
	holder := tokensHolder{}
	err := o.Rpc.Request("POST", "oauth/token", postVars, &holder)
	if err != nil {
		return nil, err
	}

	tokens := oauthTokens{
		AccessToken:  holder.AccessToken,
		RefreshToken: holder.RefreshToken,
		ExpireTime:   time.Now().UTC().Unix() + holder.ExpiresIn,
	}

	return &tokens, nil
}
func (o OAuth) GetTokens(code string, grantType string) (*oauthTokens, error) {

	postVars := map[string]string{
		"grant_type":    grantType,
		"redirect_uri":  o.RedirectUri,
		"client_id":     o.ClientId,
		"client_secret": o.ClientSecret,
	}

	if grantType == "refresh_token" {
		postVars["refresh_token"] = code
	} else {
		postVars["code"] = code
	}
	holder := tokensHolder{}
	err := o.Rpc.Request("POST", "oauth/token", postVars, &holder)
	if err != nil {
		return nil, err
	}

	tokens := oauthTokens{
		AccessToken:  holder.AccessToken,
		RefreshToken: holder.RefreshToken,
		ExpireTime:   time.Now().UTC().Unix() + holder.ExpiresIn,
	}

	return &tokens, nil
}
// GetTokens gets tokens for an OAuth user specifying a grantType (i.e authorization_code)