From 0565100c671e22e67dacff509052b3ebcbcc4394 Mon Sep 17 00:00:00 2001 From: harnishchavda_crest Date: Thu, 30 Nov 2023 18:36:04 +0530 Subject: [PATCH 01/12] support jwt authentication --- bayeux.go | 74 ++++++++++++++++++++++++++++++++++++++++++++---- examples/main.go | 3 ++ go.mod | 2 ++ go.sum | 2 ++ 4 files changed, 76 insertions(+), 5 deletions(-) diff --git a/bayeux.go b/bayeux.go index a1bbaf9..0b05553 100644 --- a/bayeux.go +++ b/bayeux.go @@ -3,6 +3,7 @@ package bayeux import ( "bytes" "context" + "crypto/rsa" "encoding/json" "errors" "fmt" @@ -14,6 +15,8 @@ import ( "os" "sync" "time" + + "github.com/golang-jwt/jwt" ) type MaybeMsg struct { @@ -100,6 +103,9 @@ type AuthenticationParameters struct { Username string // Salesforce user email (e.g. salesforce.user@email.com) Password string // Salesforce password TokenURL string // Salesforce token endpoint (e.g. https://login.salesforce.com/services/oauth2/token) + Path string // Salesforce private key path + IsJwt bool // Salesforce auth method identifier + Audience string // Salesforce authorization server’s URL for the audience value (e.g. https://login.salesforce.com or https://test.salesforce.com or https://site.force.com/customers) } // Bayeux struct allow for centralized storage of creds, ids, and cookies @@ -300,11 +306,22 @@ func GetConnectedCount() int { } func GetSalesforceCredentials(ap AuthenticationParameters) (creds *Credentials, err error) { - params := url.Values{"grant_type": {"password"}, - "client_id": {ap.ClientID}, - "client_secret": {ap.ClientSecret}, - "username": {ap.Username}, - "password": {ap.Password}} + + var params url.Values + + if ap.IsJwt { + params, err = JwtGenerator(ap) + if err != nil { + return nil, err + } + } else { + params = url.Values{"grant_type": {"password"}, + "client_id": {ap.ClientID}, + "client_secret": {ap.ClientSecret}, + "username": {ap.Username}, + "password": {ap.Password}} + } + res, err := http.PostForm(ap.TokenURL, params) if err != nil { return nil, err @@ -320,6 +337,53 @@ func GetSalesforceCredentials(ap AuthenticationParameters) (creds *Credentials, return creds, nil } +func JwtGenerator(ap AuthenticationParameters) (url.Values, error) { + // Define your JWT claims (payload) + claims := jwt.MapClaims{ + "iss": ap.ClientID, // Issuer + "sub": ap.Username, // Subject + "aud": ap.Audience, // Audience + "exp": time.Now().Add(1 * time.Minute).Unix(), // Expiration time (1 hour) + } + + // Load your private key (RSA key) used for signing + keyFile := ap.Path + privateKey, err := loadPrivateKey(keyFile) + + if err != nil { + return nil, err + } + + // Create a new JWT token + token := jwt.NewWithClaims(jwt.SigningMethodRS256, claims) + + tokenString, err := token.SignedString(privateKey) + + if err != nil { + return nil, err + } + + payload := url.Values{ + "grant_type": {"urn:ietf:params:oauth:grant-type:jwt-bearer"}, + "assertion": {tokenString}, + } + return payload, nil +} + +func loadPrivateKey(keyFile string) (*rsa.PrivateKey, error) { + keyBytes, err := os.ReadFile(keyFile) + if err != nil { + return nil, err + } + + privateKey, err := jwt.ParseRSAPrivateKeyFromPEM(keyBytes) + if err != nil { + return nil, err + } + + return privateKey, nil +} + func (b *Bayeux) Channel(ctx context.Context, out chan MaybeMsg, r string, creds Credentials, channel string) chan MaybeMsg { b.creds = creds err := b.getClientID(ctx) diff --git a/examples/main.go b/examples/main.go index 0a46747..f6240d7 100644 --- a/examples/main.go +++ b/examples/main.go @@ -12,11 +12,14 @@ func Example() { out := make(chan bay.MaybeMsg) b := bay.Bayeux{} var ap bay.AuthenticationParameters + ap.IsJwt = true ap.ClientID = "3MVG9pRsdbjsbdjfm1I.fz3f7zBuH4xdKCJcM9B5XLgxXh2AFTmQmr8JMn1vsadjsadjjsadakd_C" ap.ClientSecret = "E9FE118633BC7SGDADUHUE81F19C1D4529D09CB7231754AD2F2CA668400619" ap.Username = "salesforce.user@email.com" ap.Password = "foobar" ap.TokenURL = "https://login.salesforce.com/services/oauth2/token" + ap.Path = "/path/to/private.key" + ap.Audience = "https://login.salesforce.com" creds, _ := bay.GetSalesforceCredentials(ap) replay := "-1" c := b.Channel(ctx, out, replay, *creds, "channel") diff --git a/go.mod b/go.mod index 624345c..fe4d46a 100644 --- a/go.mod +++ b/go.mod @@ -1,3 +1,5 @@ module github.com/elastic/bayeux go 1.17 + +require github.com/golang-jwt/jwt v3.2.2+incompatible diff --git a/go.sum b/go.sum index e69de29..efdb2a9 100644 --- a/go.sum +++ b/go.sum @@ -0,0 +1,2 @@ +github.com/golang-jwt/jwt v3.2.2+incompatible h1:IfV12K8xAKAnZqdXVzCZ+TOjboZ2keLg81eXfW3O+oY= +github.com/golang-jwt/jwt v3.2.2+incompatible/go.mod h1:8pz2t5EyA70fFQQSrl6XZXzqecmYZeUEB8OUGHkxJ+I= From 9394b0c3f1d871e8039014728e3b4b86fa8c3a5a Mon Sep 17 00:00:00 2001 From: harnishchavda_crest Date: Fri, 1 Dec 2023 12:05:25 +0530 Subject: [PATCH 02/12] minor change in exp --- bayeux.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/bayeux.go b/bayeux.go index 0b05553..c2d7d4b 100644 --- a/bayeux.go +++ b/bayeux.go @@ -340,10 +340,10 @@ func GetSalesforceCredentials(ap AuthenticationParameters) (creds *Credentials, func JwtGenerator(ap AuthenticationParameters) (url.Values, error) { // Define your JWT claims (payload) claims := jwt.MapClaims{ - "iss": ap.ClientID, // Issuer - "sub": ap.Username, // Subject - "aud": ap.Audience, // Audience - "exp": time.Now().Add(1 * time.Minute).Unix(), // Expiration time (1 hour) + "iss": ap.ClientID, // Issuer + "sub": ap.Username, // Subject + "aud": ap.Audience, // Audience + "exp": time.Now().Add(1 * time.Hour).Unix(), // Expiration time (1 hour) } // Load your private key (RSA key) used for signing From 28bec80a1e17dc1cb7d29513ceeea173003e4f61 Mon Sep 17 00:00:00 2001 From: harnish-elastic <118714680+harnish-elastic@users.noreply.github.com> Date: Wed, 26 Jun 2024 15:46:46 +0530 Subject: [PATCH 03/12] Update bayeux.go Co-authored-by: Kush Rana <89848966+kush-elastic@users.noreply.github.com> --- bayeux.go | 1 - 1 file changed, 1 deletion(-) diff --git a/bayeux.go b/bayeux.go index c2d7d4b..0334c4a 100644 --- a/bayeux.go +++ b/bayeux.go @@ -306,7 +306,6 @@ func GetConnectedCount() int { } func GetSalesforceCredentials(ap AuthenticationParameters) (creds *Credentials, err error) { - var params url.Values if ap.IsJwt { From d474bce3433fc803f5b927d3bbc3c46484683cda Mon Sep 17 00:00:00 2001 From: harnish-elastic <118714680+harnish-elastic@users.noreply.github.com> Date: Wed, 26 Jun 2024 15:46:55 +0530 Subject: [PATCH 04/12] Update bayeux.go Co-authored-by: Kush Rana <89848966+kush-elastic@users.noreply.github.com> --- bayeux.go | 1 - 1 file changed, 1 deletion(-) diff --git a/bayeux.go b/bayeux.go index 0334c4a..52fce41 100644 --- a/bayeux.go +++ b/bayeux.go @@ -348,7 +348,6 @@ func JwtGenerator(ap AuthenticationParameters) (url.Values, error) { // Load your private key (RSA key) used for signing keyFile := ap.Path privateKey, err := loadPrivateKey(keyFile) - if err != nil { return nil, err } From 797ba1fb8856167104f73bc5dfce73deb47d6d27 Mon Sep 17 00:00:00 2001 From: harnish-elastic <118714680+harnish-elastic@users.noreply.github.com> Date: Wed, 26 Jun 2024 15:47:03 +0530 Subject: [PATCH 05/12] Update bayeux.go Co-authored-by: Kush Rana <89848966+kush-elastic@users.noreply.github.com> --- bayeux.go | 1 - 1 file changed, 1 deletion(-) diff --git a/bayeux.go b/bayeux.go index 52fce41..c94d7dd 100644 --- a/bayeux.go +++ b/bayeux.go @@ -356,7 +356,6 @@ func JwtGenerator(ap AuthenticationParameters) (url.Values, error) { token := jwt.NewWithClaims(jwt.SigningMethodRS256, claims) tokenString, err := token.SignedString(privateKey) - if err != nil { return nil, err } From 8ade97a3b8fc3bb5afd88a34c919b7483f35d4e7 Mon Sep 17 00:00:00 2001 From: harnish-elastic <118714680+harnish-elastic@users.noreply.github.com> Date: Wed, 26 Jun 2024 15:47:13 +0530 Subject: [PATCH 06/12] Update examples/main.go Co-authored-by: Kush Rana <89848966+kush-elastic@users.noreply.github.com> --- examples/main.go | 1 + 1 file changed, 1 insertion(+) diff --git a/examples/main.go b/examples/main.go index f6240d7..f8111d8 100644 --- a/examples/main.go +++ b/examples/main.go @@ -12,6 +12,7 @@ func Example() { out := make(chan bay.MaybeMsg) b := bay.Bayeux{} var ap bay.AuthenticationParameters + // make it false to use user-password flow ap.IsJwt = true ap.ClientID = "3MVG9pRsdbjsbdjfm1I.fz3f7zBuH4xdKCJcM9B5XLgxXh2AFTmQmr8JMn1vsadjsadjjsadakd_C" ap.ClientSecret = "E9FE118633BC7SGDADUHUE81F19C1D4529D09CB7231754AD2F2CA668400619" From 11df12989e2d2d46d726efbb8b429dda5c45f99f Mon Sep 17 00:00:00 2001 From: harnish-elastic <118714680+harnish-elastic@users.noreply.github.com> Date: Wed, 26 Jun 2024 15:47:24 +0530 Subject: [PATCH 07/12] Update bayeux.go Co-authored-by: Kush Rana <89848966+kush-elastic@users.noreply.github.com> --- bayeux.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/bayeux.go b/bayeux.go index c94d7dd..002dc20 100644 --- a/bayeux.go +++ b/bayeux.go @@ -360,11 +360,10 @@ func JwtGenerator(ap AuthenticationParameters) (url.Values, error) { return nil, err } - payload := url.Values{ + return url.Values{ "grant_type": {"urn:ietf:params:oauth:grant-type:jwt-bearer"}, "assertion": {tokenString}, - } - return payload, nil + }, nil } func loadPrivateKey(keyFile string) (*rsa.PrivateKey, error) { From b232b5c1044a791c5826e967dd278814a60bdfc0 Mon Sep 17 00:00:00 2001 From: harnish-elastic <118714680+harnish-elastic@users.noreply.github.com> Date: Wed, 26 Jun 2024 15:47:44 +0530 Subject: [PATCH 08/12] Update bayeux.go Co-authored-by: Kush Rana <89848966+kush-elastic@users.noreply.github.com> --- bayeux.go | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/bayeux.go b/bayeux.go index 002dc20..774d7f8 100644 --- a/bayeux.go +++ b/bayeux.go @@ -353,9 +353,7 @@ func JwtGenerator(ap AuthenticationParameters) (url.Values, error) { } // Create a new JWT token - token := jwt.NewWithClaims(jwt.SigningMethodRS256, claims) - - tokenString, err := token.SignedString(privateKey) + tokenString, err := jwt.NewWithClaims(jwt.SigningMethodRS256, claims).SignedString(privateKey) if err != nil { return nil, err } From 6c87ae4e8d478202655a26f1a3cf49a882975ed0 Mon Sep 17 00:00:00 2001 From: harnish-elastic <118714680+harnish-elastic@users.noreply.github.com> Date: Wed, 26 Jun 2024 15:47:55 +0530 Subject: [PATCH 09/12] Update bayeux.go Co-authored-by: Kush Rana <89848966+kush-elastic@users.noreply.github.com> --- bayeux.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/bayeux.go b/bayeux.go index 774d7f8..faa22f4 100644 --- a/bayeux.go +++ b/bayeux.go @@ -346,8 +346,7 @@ func JwtGenerator(ap AuthenticationParameters) (url.Values, error) { } // Load your private key (RSA key) used for signing - keyFile := ap.Path - privateKey, err := loadPrivateKey(keyFile) + privateKey, err := loadPrivateKey(ap.Path) if err != nil { return nil, err } From f21ba1f8c6e905bfef38404501e9f1f20bd915d9 Mon Sep 17 00:00:00 2001 From: harnish-elastic Date: Mon, 8 Jul 2024 15:55:17 +0530 Subject: [PATCH 10/12] resolve lint error --- examples/main.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/main.go b/examples/main.go index f8111d8..6ac3a74 100644 --- a/examples/main.go +++ b/examples/main.go @@ -12,7 +12,7 @@ func Example() { out := make(chan bay.MaybeMsg) b := bay.Bayeux{} var ap bay.AuthenticationParameters - // make it false to use user-password flow + // make it false to use user-password flow ap.IsJwt = true ap.ClientID = "3MVG9pRsdbjsbdjfm1I.fz3f7zBuH4xdKCJcM9B5XLgxXh2AFTmQmr8JMn1vsadjsadjjsadakd_C" ap.ClientSecret = "E9FE118633BC7SGDADUHUE81F19C1D4529D09CB7231754AD2F2CA668400619" From 420915196cb52ace449cb86c69ceaf5ac1b185f2 Mon Sep 17 00:00:00 2001 From: harnish-elastic Date: Thu, 22 Aug 2024 11:26:06 +0530 Subject: [PATCH 11/12] method refactor --- bayeux.go | 76 ++++++++++++++++++++++++++++++++++++++---------- example_test.go | 8 ++++- examples/main.go | 5 +++- 3 files changed, 71 insertions(+), 18 deletions(-) diff --git a/bayeux.go b/bayeux.go index faa22f4..1feefb3 100644 --- a/bayeux.go +++ b/bayeux.go @@ -114,6 +114,10 @@ type Bayeux struct { id clientIDAndCookies } +type Authentication struct { + URLValues *url.Values + AuthParameters *AuthenticationParameters +} var wg sync.WaitGroup var logger = log.New(os.Stdout, "", log.Ldate|log.Ltime|log.Lmicroseconds|log.Lshortfile) var st = status{false, "", []string{}, 0} @@ -305,29 +309,37 @@ func GetConnectedCount() int { return st.connectCount } -func GetSalesforceCredentials(ap AuthenticationParameters) (creds *Credentials, err error) { - var params url.Values +func GetSalesforceCredentials(auth Authentication) (creds *Credentials, err error) { + var params* Authentication - if ap.IsJwt { - params, err = JwtGenerator(ap) + if auth.AuthParameters == nil { + return nil, fmt.Errorf("auth parameters are empty") + } + if auth.AuthParameters.IsJwt { + params, err = GetJWTAuthentication(*auth.AuthParameters) if err != nil { return nil, err } } else { - params = url.Values{"grant_type": {"password"}, - "client_id": {ap.ClientID}, - "client_secret": {ap.ClientSecret}, - "username": {ap.Username}, - "password": {ap.Password}} + + if auth.AuthParameters.ClientID == "" || auth.AuthParameters.ClientSecret == "" || auth.AuthParameters.Username == "" || auth.AuthParameters.Password == "" { + return nil, fmt.Errorf("missing required authentication parameters") + } + params,_ = GetClientCredentialAuthentication(auth.AuthParameters.ClientID, auth.AuthParameters.ClientSecret, auth.AuthParameters.Username, auth.AuthParameters.Password, auth.AuthParameters.TokenURL) } + if auth.AuthParameters.TokenURL == "" { + return nil, fmt.Errorf("missing required authentication parameter: token_url") + } - res, err := http.PostForm(ap.TokenURL, params) + res, err := http.PostForm(auth.AuthParameters.TokenURL, *params.URLValues) if err != nil { - return nil, err + return nil, fmt.Errorf("error posting form: %w", err) } + defer res.Body.Close() + decoder := json.NewDecoder(res.Body) if err := decoder.Decode(&creds); err == io.EOF { - return nil, err + return nil, fmt.Errorf("error decoding response: %w", err) } else if err != nil { return nil, err } else if creds.AccessToken == "" { @@ -336,7 +348,8 @@ func GetSalesforceCredentials(ap AuthenticationParameters) (creds *Credentials, return creds, nil } -func JwtGenerator(ap AuthenticationParameters) (url.Values, error) { +// GetJWTAuthentication prepares the authentication parameters for JWT-based authentication +func GetJWTAuthentication(ap AuthenticationParameters) (*Authentication, error) { // Define your JWT claims (payload) claims := jwt.MapClaims{ "iss": ap.ClientID, // Issuer @@ -348,21 +361,52 @@ func JwtGenerator(ap AuthenticationParameters) (url.Values, error) { // Load your private key (RSA key) used for signing privateKey, err := loadPrivateKey(ap.Path) if err != nil { - return nil, err + return nil, fmt.Errorf("Error loading private key: %w", err) } // Create a new JWT token tokenString, err := jwt.NewWithClaims(jwt.SigningMethodRS256, claims).SignedString(privateKey) if err != nil { - return nil, err + return nil, fmt.Errorf("Error signing JWT token: %w", err) } - return url.Values{ + return &Authentication{ + URLValues: &url.Values{ "grant_type": {"urn:ietf:params:oauth:grant-type:jwt-bearer"}, "assertion": {tokenString}, + }, + AuthParameters: &AuthenticationParameters{ + ClientSecret: ap.ClientSecret, + Username: ap.Username, + Audience: ap.Audience, + Path: ap.Path, + }, }, nil } +// GetClientCredentialAuthentication prepares the authentication parameters for client credential-based authentication +func GetClientCredentialAuthentication(clientId, clientSecret, username, password, tokenUrl string) (*Authentication, error) { + if clientId !="" && clientSecret !="" && username !="" && password !="" && tokenUrl !="" { + return nil, errors.New("all authentication parameters must be set") + } + + return &Authentication{ + URLValues: &url.Values{ + "grant_type": {"password"}, + "client_id": {clientId}, + "client_secret": {clientSecret}, + "username": {username}, + "password": {password}, + }, + AuthParameters: &AuthenticationParameters{ + ClientID: clientId, + ClientSecret: clientSecret, + Username: username, + Password: password, + TokenURL: tokenUrl, + }, + }, nil +} func loadPrivateKey(keyFile string) (*rsa.PrivateKey, error) { keyBytes, err := os.ReadFile(keyFile) if err != nil { diff --git a/example_test.go b/example_test.go index 82ede55..9ee445f 100644 --- a/example_test.go +++ b/example_test.go @@ -17,7 +17,13 @@ func Example() { ap.Username = "salesforce.user@email.com" ap.Password = "foobar" ap.TokenURL = "https://login.salesforce.com/services/oauth2/token" - creds, _ := GetSalesforceCredentials(ap) + + //Create a variable of type Authentication + auth:=Authentication{ + AuthParameters: &ap, + } + + creds, _ := GetSalesforceCredentials(auth) c := b.Channel(ctx, out, replay, *creds, "channel") for { select { diff --git a/examples/main.go b/examples/main.go index 6ac3a74..23302c5 100644 --- a/examples/main.go +++ b/examples/main.go @@ -21,7 +21,10 @@ func Example() { ap.TokenURL = "https://login.salesforce.com/services/oauth2/token" ap.Path = "/path/to/private.key" ap.Audience = "https://login.salesforce.com" - creds, _ := bay.GetSalesforceCredentials(ap) + auth:=bay.Authentication{ + AuthParameters: &ap, + } + creds, _ := bay.GetSalesforceCredentials(auth) replay := "-1" c := b.Channel(ctx, out, replay, *creds, "channel") for { From 757c58afffae3468482d5585b5ce6f89c03facf8 Mon Sep 17 00:00:00 2001 From: harnish-elastic Date: Tue, 27 Aug 2024 11:26:48 +0530 Subject: [PATCH 12/12] format go files --- bayeux.go | 37 +++++++++++++++++++------------------ example_test.go | 4 ++-- examples/main.go | 2 +- 3 files changed, 22 insertions(+), 21 deletions(-) diff --git a/bayeux.go b/bayeux.go index 1feefb3..50e109e 100644 --- a/bayeux.go +++ b/bayeux.go @@ -118,6 +118,7 @@ type Authentication struct { URLValues *url.Values AuthParameters *AuthenticationParameters } + var wg sync.WaitGroup var logger = log.New(os.Stdout, "", log.Ldate|log.Ltime|log.Lmicroseconds|log.Lshortfile) var st = status{false, "", []string{}, 0} @@ -310,7 +311,7 @@ func GetConnectedCount() int { } func GetSalesforceCredentials(auth Authentication) (creds *Credentials, err error) { - var params* Authentication + var params *Authentication if auth.AuthParameters == nil { return nil, fmt.Errorf("auth parameters are empty") @@ -325,11 +326,11 @@ func GetSalesforceCredentials(auth Authentication) (creds *Credentials, err erro if auth.AuthParameters.ClientID == "" || auth.AuthParameters.ClientSecret == "" || auth.AuthParameters.Username == "" || auth.AuthParameters.Password == "" { return nil, fmt.Errorf("missing required authentication parameters") } - params,_ = GetClientCredentialAuthentication(auth.AuthParameters.ClientID, auth.AuthParameters.ClientSecret, auth.AuthParameters.Username, auth.AuthParameters.Password, auth.AuthParameters.TokenURL) + params, _ = GetClientCredentialAuthentication(auth.AuthParameters.ClientID, auth.AuthParameters.ClientSecret, auth.AuthParameters.Username, auth.AuthParameters.Password, auth.AuthParameters.TokenURL) } if auth.AuthParameters.TokenURL == "" { - return nil, fmt.Errorf("missing required authentication parameter: token_url") - } + return nil, fmt.Errorf("missing required authentication parameter: token_url") + } res, err := http.PostForm(auth.AuthParameters.TokenURL, *params.URLValues) if err != nil { @@ -372,31 +373,31 @@ func GetJWTAuthentication(ap AuthenticationParameters) (*Authentication, error) return &Authentication{ URLValues: &url.Values{ - "grant_type": {"urn:ietf:params:oauth:grant-type:jwt-bearer"}, - "assertion": {tokenString}, - }, - AuthParameters: &AuthenticationParameters{ - ClientSecret: ap.ClientSecret, - Username: ap.Username, - Audience: ap.Audience, - Path: ap.Path, - }, + "grant_type": {"urn:ietf:params:oauth:grant-type:jwt-bearer"}, + "assertion": {tokenString}, + }, + AuthParameters: &AuthenticationParameters{ + ClientSecret: ap.ClientSecret, + Username: ap.Username, + Audience: ap.Audience, + Path: ap.Path, + }, }, nil } // GetClientCredentialAuthentication prepares the authentication parameters for client credential-based authentication func GetClientCredentialAuthentication(clientId, clientSecret, username, password, tokenUrl string) (*Authentication, error) { - if clientId !="" && clientSecret !="" && username !="" && password !="" && tokenUrl !="" { + if clientId != "" && clientSecret != "" && username != "" && password != "" && tokenUrl != "" { return nil, errors.New("all authentication parameters must be set") } return &Authentication{ URLValues: &url.Values{ - "grant_type": {"password"}, - "client_id": {clientId}, + "grant_type": {"password"}, + "client_id": {clientId}, "client_secret": {clientSecret}, - "username": {username}, - "password": {password}, + "username": {username}, + "password": {password}, }, AuthParameters: &AuthenticationParameters{ ClientID: clientId, diff --git a/example_test.go b/example_test.go index 9ee445f..ef056d5 100644 --- a/example_test.go +++ b/example_test.go @@ -18,8 +18,8 @@ func Example() { ap.Password = "foobar" ap.TokenURL = "https://login.salesforce.com/services/oauth2/token" - //Create a variable of type Authentication - auth:=Authentication{ + //Create a variable of type Authentication + auth := Authentication{ AuthParameters: &ap, } diff --git a/examples/main.go b/examples/main.go index 23302c5..6e7d4b2 100644 --- a/examples/main.go +++ b/examples/main.go @@ -21,7 +21,7 @@ func Example() { ap.TokenURL = "https://login.salesforce.com/services/oauth2/token" ap.Path = "/path/to/private.key" ap.Audience = "https://login.salesforce.com" - auth:=bay.Authentication{ + auth := bay.Authentication{ AuthParameters: &ap, } creds, _ := bay.GetSalesforceCredentials(auth)