gcp

package
v0.36.0 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2026 License: Apache-2.0 Imports: 23 Imported by: 7 modules, 11 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Examples

Constants

This section is empty.

Variables

View Source
var Scopes = []string{
	"openid",
	"https://www.googleapis.com/auth/userinfo.email",
	"https://www.googleapis.com/auth/cloud-platform",
	"https://www.googleapis.com/auth/compute",
	"https://www.googleapis.com/auth/accounts.reauth",
}

Scopes defines default auth scopes

Functions

func JwtClaims

func JwtClaims(ctx context.Context, tokenString string) (*sjwt.Claims, error)

JwtClaims extract token info, but it does not verify token

Types

type Service

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

func New

func New(config *oauth2.Config) *Service

func (*Service) Auth

func (s *Service) Auth(ctx context.Context, scopes ...string) (*auth.Token, error)

func (*Service) AuthClient

func (s *Service) AuthClient(ctx context.Context, scopes ...string) (*http.Client, error)

AuthClient returns auth HTTP config

func (*Service) Config

func (s *Service) Config(scopes ...string) *oauth2.Config

func (*Service) IDClient

func (s *Service) IDClient(ctx context.Context, audience string, scopes ...string) (*http.Client, error)

IDClient returns identity token HTTP config

Example
package main

import (
	"context"
	"fmt"
	"github.com/viant/scy/auth/gcp"
	"github.com/viant/scy/auth/gcp/client"
	"io/ioutil"
	"log"
)

func main() {
	srv := gcp.New(client.NewScy())
	ctx := context.Background()
	audience := "https://us-central1-myProject.cloudfunctions.net/MyCloudFunction"
	httpClient, err := srv.IDClient(ctx, audience)
	//Call secured cloud function
	resp, err := httpClient.Get(audience)
	if err != nil {
		log.Fatal(err)
	}
	data, err := ioutil.ReadAll(resp.Body)
	if err != nil {
		log.Fatal(err)
	}
	fmt.Printf("CF response: %s\n", data)
}

func (*Service) IDToken

func (s *Service) IDToken(ctx context.Context, audience string, scopes ...string) (*oauth2.Token, error)

func (*Service) ProjectID added in v0.9.0

func (s *Service) ProjectID(ctx context.Context) string

func (*Service) TokenSource

func (s *Service) TokenSource(scopes ...string) oauth2.TokenSource

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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