Documentation ¶
Index ¶
- Variables
- func JwtClaims(ctx context.Context, tokenString string) (*sjwt.Claims, error)
- type Client
- type Service
- func (s *Service) Auth(ctx context.Context, scopes ...string) (*auth.Token, error)
- func (s *Service) AuthClient(ctx context.Context, scopes ...string) (*http.Client, error)
- func (s *Service) Config(ctx context.Context, scopes ...string) *oauth2.Config
- func (s *Service) IDClient(ctx context.Context, audience string, scopes ...string) (*http.Client, error)
- func (s *Service) IDToken(ctx context.Context, audience string, scopes ...string) (*oauth2.Token, error)
- func (s *Service) TokenSource(scopes ...string) oauth2.TokenSource
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 ¶
Types ¶
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
func (*Service) AuthClient ¶
AuthClient returns auth HTTP client
func (*Service) IDClient ¶
func (s *Service) IDClient(ctx context.Context, audience string, scopes ...string) (*http.Client, error)
IDClient returns identity token HTTP client
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) }
Output:
func (*Service) TokenSource ¶
func (s *Service) TokenSource(scopes ...string) oauth2.TokenSource
Click to show internal directories.
Click to hide internal directories.