Index | Files

package oauth

import ""

Package oauth provides oauth capabilities to barista and modules.


Package Files

crypt.go oauth.go

func InteractiveSetup Uses

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 Uses

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.

type Config Uses

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 Uses

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 Uses

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 Uses

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

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

Package oauth imports 22 packages (graph) and is imported by 7 packages. Updated 2020-10-17. Refresh now. Tools for package owners.