Não pode escolher mais do que 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.
 
 
 

34 linhas
990 B

  1. // Copyright 2014 The Go Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style
  3. // license that can be found in the LICENSE file.
  4. package jwt_test
  5. import (
  6. "context"
  7. "golang.org/x/oauth2/jwt"
  8. )
  9. func ExampleJWTConfig() {
  10. ctx := context.Background()
  11. conf := &jwt.Config{
  12. Email: "xxx@developer.com",
  13. // The contents of your RSA private key or your PEM file
  14. // that contains a private key.
  15. // If you have a p12 file instead, you
  16. // can use `openssl` to export the private key into a pem file.
  17. //
  18. // $ openssl pkcs12 -in key.p12 -out key.pem -nodes
  19. //
  20. // It only supports PEM containers with no passphrase.
  21. PrivateKey: []byte("-----BEGIN RSA PRIVATE KEY-----..."),
  22. Subject: "user@example.com",
  23. TokenURL: "https://provider.com/o/oauth2/token",
  24. }
  25. // Initiate an http.Client, the following GET request will be
  26. // authorized and authenticated on the behalf of user@example.com.
  27. client := conf.Client(ctx)
  28. client.Get("...")
  29. }