Пример #1
0
// New initiates a new DriveService.
func New(transport *oauth.Transport, parentId string) (*DriveService, error) {
	apiservice, err := client.New(transport.Client())
	if err != nil {
		return nil, err
	}
	service := &DriveService{transport: transport, apiservice: apiservice, parentId: parentId}
	return service, err
}
Пример #2
0
// NewAuthorizeHandler returns a http.HandlerFunc which will set the Token of
// the given oauth.Transport and send a struct{} on the donech on success.
func NewAuthorizeHandler(transport *oauth.Transport, donech chan<- struct{}) http.HandlerFunc {
	return func(w http.ResponseWriter, r *http.Request) {
		token, err := transport.Exchange(r.FormValue("code"))
		if err != nil {
			http.Error(w, fmt.Sprintf("error exchanging code: %v", err), http.StatusBadRequest)
			return
		}
		transport.Token = token
		// The Transport now has a valid Token.
		donech <- struct{}{}
	}
}
Пример #3
0
func NewClient(transport *oauth.Transport) *Client {
	return &Client{transport, transport.Client()}
}