oauth

package
v0.0.0-...-53571a8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 23, 2020 License: MIT Imports: 14 Imported by: 0

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

View Source
const (
	DefaultTokenExchangeURL = "https://accounts.google.com/o/oauth2/token"
	DefaultFeedUploadURL    = "https://partnerdash.google.com/push-upload"
)

Variables

View Source
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

type FeedMessageWrapper struct {
	Name string
	File io.Reader
}

FeedMessageWrapper encapsulates GTFS-realtime dataset along with its filename. When communicating with Google - Name is an optional field to fill.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL