weatherkitauth

package module
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2022 License: MIT Imports: 4 Imported by: 0

README

go-weatherkitauth

A library & command line application for generating WeatherKit REST API authentication tokens. See the WeatherKit documentation here for more details.

go-weatherkitauth is an open source project not affiliated with Apple Inc.

Locating your identifiers:
Use as a library:

// Initialize a token generator.
generator := weatherkitauth.TokenGenerator{
  KeyID:     "keyId",
  TeamID:    "teamId",
  ServiceID: "serviceId",
  Duration:  time.Minute * 30,
}

// Fetch your private key bytes. 
bytes, err := os.ReadFile(privateKeyFilePath)

// Generate a signed JWT string.
token, err := generator.GenerateSignedJWT(bytes)

Use as a binary application:

Precompiled binaries are available on the Releases page.

Usage of ./weatherkitauth:
  -d duration
        How long the token will be valid for. (default 30m0s)
  -kid string
        (required) The Key ID associated with your private key.
  -pk string
        (required) The path to a file containing your PEM encoded private key.
  -sid string
        (required) The Service ID from your developer account.
  -tid string
        (required) The Team ID from your developer account.
  -v    Print the version of this application.
./weatherkitauth -pk AuthKey_ABCDE12345.p8 -kid keyId -sid serviceId -tid teamId

Troubleshooting

Please use the GitHub Discussions tab for questions regarding this client library. The Apple Developer forums are available for questions regarding the underlying WeatherKit API: https://developer.apple.com/forums/tags/weatherkit

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type TokenGenerator

type TokenGenerator struct {
	// KeyID is the Key identifier from your developer accoung.
	KeyID string

	// TeamID is the Team ID from your developer accoung.
	TeamID string

	// ServiceID is the Service ID from your developer accoung.
	ServiceID string

	// Duration is how long the token will be valid for.
	Duration time.Duration
}

TokenGenerator generates authentication tokens for apple REST APIs.

func (*TokenGenerator) GenerateSignedJWT

func (g *TokenGenerator) GenerateSignedJWT(pemBytes []byte) (string, error)

GenerateSignedJWT generates a valid JWT signed with your PEM private key.

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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