ogle

package module
v0.1.0-beta2 Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2022 License: Apache-2.0 Imports: 16 Imported by: 0

README

ogle is a toolkit to interact with Google APIs

Go Reference

Warning: this is a work in progress, subject to change.

Install

To install these tools you need the Go programming language, version 1.16 or later, in your machine. Follow the setup instructions from the official website

Once Go is installed, you can then install the commands by running:

go install github.com/ronoaldo/ogle/cmd/...@latest

Commands

Each command is designed to be used as a standalone command line tool, and be integrated with any Unix toolchain.

youtube

youtube is a command line interface to interact with your Youtube channel. It allows you to list your channel details, playlists, playlist vídeos.

Documentation

Overview

Package ogle provides basic and commong utilities to interact with Google APIs from installed apps.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Authorize

func Authorize(ctx context.Context, config *oauth2.Config) (*oauth2.Token, error)

Authorized launches the OAuth2 flow, by listening to a random port on localhost. It returns the granted oauth2.Token if the flow completes sucessfully. It will report any error during the process, including the user not authorizing the client at all or an error during the token exchange.

func LoadTokenFromCache

func LoadTokenFromCache(api string) (*oauth2.Token, error)

LoadTokenFromCache reads the cache file for the provided API and returns a parsed oauth2.Token pointer, or an error if either the file cannot be read or the token is invalid.

func NewClient

func NewClient(ctx context.Context, api string, scopes ...string) (c *http.Client, err error)

NewClient creates a new http.Client that will authorizes calls with the token stored for the given API name in the cache file.

NewClient is designed to provide a valid token when called, for convenience. This implies that if there is no cached credentials, it will start an OAuth2 flow by calling Authorize.

func RemoveTokenFromCache

func RemoveTokenFromCache(api string) error

RemoveTokenFromCache will remove the cache file for the provided API. Future requests using that api name will require re-authentication.

func SaveTokenToCache

func SaveTokenToCache(api string, token *oauth2.Token) error

SaveTokenToCache saves the given oauth2.Token to the cache file. It returns an error if the cache file cannot be written.

Types

type TabWriter

type TabWriter struct {
	// contains filtered or unexported fields
}

TabWriter is a thin wrapper around `text/tabwriter` that prints any interface{} value.

func NewTabWriter

func NewTabWriter(w io.Writer) *TabWriter

NewTabWriter initializes a TabWriter object with sane defaults shared by all Ogle API clients.

func (*TabWriter) Flush

func (tw *TabWriter) Flush() error

Flush ensures that the data is written to the underlying io.Writer by calling the wrapped tabwriter.Flush corresponding method.

func (*TabWriter) Println

func (tw *TabWriter) Println(args ...interface{})

Println prints the provided values in tab separated columns, using the '%v' format string for each one.

Directories

Path Synopsis
cmd
youtube
Command youtube allows you to interact with the Youtube service using a command line interface.
Command youtube allows you to interact with the Youtube service using a command line interface.

Jump to

Keyboard shortcuts

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