oauth

package
v0.0.0-...-cb77e8e Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2019 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Overview

Package oauth provides oauth capabilities to barista and modules.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InteractiveSetup

func InteractiveSetup()

InteractiveSetup checks each registered config and guides the user through a command-line interactive auth process for each config that doesn't have a valid token. Only intended for use by barista's Run() method, calling it at the wrong time can leave you unable to save tokens for some configs.

func SetEncryptionKey

func SetEncryptionKey(key []byte)

SetEncryptionKey sets the global encryption key for the oauth package. All site-specific encryption keys are derived from the global encryption key. For that reason this is a very high-value key, and should be stored properly, for example, using libsecret.

Types

type Config

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

Config represents a oauth configuration for use in barista. It can be used to create an authenticated client after the user has setup oauth for barista using the InteractiveSetup() method.

func Register

func Register(config *oauth2.Config) *Config

Register registers an oauth2 configuration with barista's oauth package. Only configurations that are registered *before* Run() is called will be added to the interactive oauth setup, so modules should usually call this either in init() or in their New() functions.

func (*Config) Client

func (c *Config) Client() (*http.Client, error)

Client returns an http client that authorises requests using the previously saved token for this configuration.

func (*Config) Token

func (c *Config) Token() (*oauth2.Token, error)

Token makes Config a TokenSource, in a way that automatically saves any newly fetched tokens to disk.

Jump to

Keyboard shortcuts

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