Documentation ¶
Overview ¶
Package oauth implements communication with the Google Realtime Transit API. It's based on https://support.google.com/transitpartners/answer/2529132?hl=en&ref_topic=2527461.
Index ¶
Constants ¶
const ( DefaultTokenExchangeURL = "https://accounts.google.com/o/oauth2/token" DefaultFeedUploadURL = "https://partnerdash.google.com/push-upload" )
Variables ¶
var ErrChanClosed = errors.New("streaming channel is closed")
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func NewClient ¶
func NewClient( httpClient *http.Client, clientSecretJSON io.Reader, tokensCachePath, tokenExchangeURL, authorizationCode, feedUploadURL string) (*Client, error)
NewClient returns initialized Client and any error encountered. It performs exchange automatically if no tokens have been found in the tokensCachePath.
clientSecretJSON file should be the default one provided by Google.
func (*Client) Run ¶
func (c *Client) Run( feedProvider provider.FeedProvider, feedFilename, alkaliAccountID, realtimeFeedID string) error
Run makes it easier for Data Sources to push GTFS-realtime dataset continuously. Data Source is an implementation of the provider.FeedProvider.
It automatically refreshes Access Token.
The alkaliAccountID is the value of the "a" parameter in the Transit Partner Dashboard page URL.
func (*Client) UploadFeedMessage ¶
func (c *Client) UploadFeedMessage( alkaliAccountID, realtimeFeedID string, wrapper FeedMessageWrapper) error
UploadFeedMessage uploads GTFS-realtime dataset and returns any error encountered.
It automatically refreshes Access Token.
The alkaliAccountID is the value of the "a" parameter in the Transit Partner Dashboard page URL.
type FeedMessageWrapper ¶
FeedMessageWrapper encapsulates GTFS-realtime dataset along with its filename. When communicating with Google - Name is an optional field to fill.