func GenerateToken(c *http.Client, baseURL, clientID, clientSecret, code string) (Token, http.Header, error) {
	body := fmt.Sprintf(`{"grant_type": "authorization_code", "code": "%s"}`, code)
	r, err := http.NewRequest("POST", baseURL+"/oauth/token", strings.NewReader(body))
	if err != nil {
		return Token{}, nil, err
	}
	r.Header.Set("Content-Type", "application/json")
	r.SetBasicAuth(clientID, clientSecret)
	rsp, err := c.Do(r)
	if err != nil {
		return Token{}, nil, err
	}
	defer drainAndClose(rsp.Body)
	if rsp.StatusCode != 200 {
		return Token{}, rsp.Header, lyft.NewStatusError(rsp)
	}
	var g token
	if err := unmarshal(rsp.Body, &g); err != nil {
		return Token{}, rsp.Header, err
	}
	return Token{
		AccessToken:  g.AccessToken,
		RefreshToken: g.RefreshToken,
		TokenType:    g.TokenType,
		Expires:      time.Second * time.Duration(g.Expires),
		Scopes:       strings.Fields(g.Scopes),
	}, rsp.Header, nil
}
GenerateToken creates a new access token using the authorization code
obtained from Lyft's authorization redirect. The access token
returned can be used in lyft.Client. baseURL is typically lyft.BaseURL.
package threeleg
import (
	"encoding/json"
	"fmt"
	"io"
	"io/ioutil"
	"net/http"
	"net/url"
	"strings"
	"time"
	"github.com/nishanths/lyft-go"
)
func AuthorizationURL(clientID string, scopes []string, state string) string {
	v := make(url.Values)
	v.Set("client_id", clientID)
	v.Set("response_type", "code")  
	v.Set("scope", strings.Join(scopes, " "))
	v.Set("state", state)
	return fmt.Sprintf("https://api.lyft.com/oauth/authorize?%s", v.Encode())
}
func AuthorizationCode(r *http.Request) string {
	return r.FormValue("code")
}
type Token struct {
	AccessToken  string
	RefreshToken string
	TokenType    string
	Expires      time.Duration
	Scopes       []string
}
type token struct {
	AccessToken  string `json:"access_token"`
	RefreshToken string `json:"refresh_token"`
	TokenType    string `json:"token_type"`
	Expires      int64  `json:"expires_in"`  
	Scopes       string `json:"scope"`       
}
type RefreshedToken struct {
	AccessToken string
	TokenType   string
	Expires     time.Duration
	Scopes      []string
}
type refreshedToken struct {
	AccessToken string `json:"access_token"`
	TokenType   string `json:"token_type"`
	Expires     int64  `json:"expires_in"`  
	Scopes      string `json:"scope"`       
}