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 5 package jwt_test 6 7 import ( 8 "context" 9 10 "golang.org/x/oauth2/jwt" 11 ) 12 13 func ExampleJWTConfig() { 14 ctx := context.Background() 15 conf := &jwt.Config{ 16 Email: "xxx@developer.com", 17 // The contents of your RSA private key or your PEM file 18 // that contains a private key. 19 // If you have a p12 file instead, you 20 // can use `openssl` to export the private key into a pem file. 21 // 22 // $ openssl pkcs12 -in key.p12 -out key.pem -nodes 23 // 24 // It only supports PEM containers with no passphrase. 25 PrivateKey: []byte("-----BEGIN RSA PRIVATE KEY-----..."), 26 Subject: "user@example.com", 27 TokenURL: "https://provider.com/o/oauth2/token", 28 } 29 // Initiate an http.Client, the following GET request will be 30 // authorized and authenticated on the behalf of user@example.com. 31 client := conf.Client(ctx) 32 client.Get("...") 33 } 34