morningstar

package
v1.2.0-alpha Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2022 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Examples

Constants

View Source
const (
	HouseholdsPath rawPath
)
View Source
const (
	HouseholdsRatelimiter ratelimiter
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct{ http.Client }

Client is a wrapper for http.Client.

func NewClient

func NewClient(_ context.Context, roundtripper transport.T) (*Client, error)

NewClient will return a new HTTP client to interface with the Morningstar API.

type Token

type Token struct {
	AccessToken string `bson:"access_token" json:"access_token" sql:"access_token"`
	ExpiresIn   int    `bson:"expires_in" json:"expires_in" sql:"expires_in"`
	TokenType   string `bson:"token_type" json:"token_type" sql:"token_type"`
}

Token is an OAuth bearer token authorized using a base64-encoded user id and password.

func NewBearerToken

func NewBearerToken(url, username, password string) (*Token, error)

NewBearerToken will generate a bearer token with base64-encrypted username and password.

Example
package main

import (
	"log"
	"os"

	"github.com/alpine-hodler/web/pkg/morningstar"
)

func main() {
	url := "https://www.us-api.morningstar.com/token/oauth"
	username := os.Getenv("MORNINGSTAR_USERNAME")
	password := os.Getenv("MORNINGSTAR_PASSWORD")

	token, err := morningstar.NewBearerToken(url, username, password)
	if err != nil {
		log.Fatalf("error posting client credentials: %v", err)
	}

	// Do something with our token
	os.Setenv("MORNINGSTAR_BEARER_TOKEN", token.AccessToken)
}
Output:

Jump to

Keyboard shortcuts

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