Docs improvements, lint error fixes.

This commit is contained in:
Burcu Dogan 2014-08-13 13:40:18 -07:00
parent 03e5fbeae0
commit f9dc7568c2
4 changed files with 12 additions and 12 deletions

View File

@ -56,7 +56,7 @@ func Example_jWTConfig() {
// The path to the pem file. If you have a p12 file instead, you // The path to the pem file. If you have a p12 file instead, you
// can use `openssl` to export the private key into a pem file. // can use `openssl` to export the private key into a pem file.
// $ openssl pkcs12 -in key.p12 -out key.pem -nodes // $ openssl pkcs12 -in key.p12 -out key.pem -nodes
PemFilename: "/path/to/pem/file.pem", PEMFilename: "/path/to/pem/file.pem",
Scopes: []string{"SCOPE1", "SCOPE2"}, Scopes: []string{"SCOPE1", "SCOPE2"},
}, },
"https://provider.com/o/oauth2/token") "https://provider.com/o/oauth2/token")

View File

@ -49,10 +49,10 @@ func Example_serviceAccounts() {
// Developer Console (https://console.developers.google.com). // Developer Console (https://console.developers.google.com).
config, err := google.NewServiceAccountConfig(&oauth2.JWTOptions{ config, err := google.NewServiceAccountConfig(&oauth2.JWTOptions{
Email: "xxx@developer.gserviceaccount.com", Email: "xxx@developer.gserviceaccount.com",
// The path to the pem file. If you have a p12 file instead, you // PEMFilename. If you have a p12 file instead, you
// can use `openssl` to export the private key into a pem file. // can use `openssl` to export the private key into a pem file.
// $ openssl pkcs12 -in key.p12 -out key.pem -nodes // $ openssl pkcs12 -in key.p12 -out key.pem -nodes
PemFilename: "/path/to/pem/file.pem", PEMFilename: "/path/to/pem/file.pem",
Scopes: []string{ Scopes: []string{
"https://www.googleapis.com/auth/bigquery", "https://www.googleapis.com/auth/bigquery",
}, },

14
jwt.go
View File

@ -27,21 +27,21 @@ var (
// JWTOptions represents a OAuth2 client's crendentials to retrieve a // JWTOptions represents a OAuth2 client's crendentials to retrieve a
// Bearer JWT token. // Bearer JWT token.
type JWTOptions struct { type JWTOptions struct {
// ClientID is the OAuth client identifier used when communicating with // Email is the OAuth client identifier used when communicating with
// the configured OAuth provider. // the configured OAuth provider.
Email string `json:"email"` Email string `json:"email"`
// Private key to sign JWS payloads. // PrivateKey is an RSA private key to sign JWS payloads.
PrivateKey *rsa.PrivateKey `json:"-"` PrivateKey *rsa.PrivateKey `json:"-"`
// The path to a pem container that includes your private key. // The path to a PEM container that includes your private key.
// If PrivateKey is set, this field is ignored. // If PrivateKey is set, this field is ignored.
// //
// If you have a p12 file instead, you // If you have a p12 file instead, you
// can use `openssl` to export the private key into a pem file. // can use `openssl` to export the private key into a PEM file.
// $ openssl pkcs12 -in key.p12 -out key.pem -nodes // $ openssl pkcs12 -in key.p12 -out key.pem -nodes
// Pem file should contain your private key. // PEM file should contain your private key.
PemFilename string `json:"pemfilename"` PEMFilename string `json:"pemfilename"`
// Scopes identify the level of access being requested. // Scopes identify the level of access being requested.
Scopes []string `json:"scopes"` Scopes []string `json:"scopes"`
@ -57,7 +57,7 @@ func NewJWTConfig(opts *JWTOptions, aud string) (*JWTConfig, error) {
if opts.PrivateKey != nil { if opts.PrivateKey != nil {
return &JWTConfig{opts: opts, aud: audURL, key: opts.PrivateKey}, nil return &JWTConfig{opts: opts, aud: audURL, key: opts.PrivateKey}, nil
} }
contents, err := ioutil.ReadFile(opts.PemFilename) contents, err := ioutil.ReadFile(opts.PEMFilename)
if err != nil { if err != nil {
return nil, err return nil, err
} }

View File

@ -61,8 +61,8 @@ type Options struct {
// granting (or denying) access. // granting (or denying) access.
RedirectURL string `json:"redirect_url"` RedirectURL string `json:"redirect_url"`
// Optional, identifies the level of access being requested. // Scopes optionally specifies a list of requested permission scopes.
Scopes []string `json:"scopes"` Scopes []string `json:"scopes,omitempty"`
// AccessType is an OAuth extension that gets sent as the // AccessType is an OAuth extension that gets sent as the
// "access_type" field in the URL from AuthCodeURL. // "access_type" field in the URL from AuthCodeURL.