This is an automated email from the ASF dual-hosted git repository.

rxl pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/pulsar.git


The following commit(s) were added to refs/heads/master by this push:
     new 24fa8cf  [doc] Add pulsar-client-go oauth2 authentication document 
(#7648)
24fa8cf is described below

commit 24fa8cfcbe77faec66db66a478182709dad74bd8
Author: Yong Zhang <zhangyong1025...@gmail.com>
AuthorDate: Tue Jul 28 19:40:52 2020 +0800

    [doc] Add pulsar-client-go oauth2 authentication document (#7648)
    
    * [doc] Add pulsar-client-go oauth2 authentication document
    ---
    
    *Motivation*
    
    Add pulsar-client-go oauth2 authentication usage document.
    
    * Address comments
---
 site2/docs/client-libraries-go.md | 19 +++++++++++++++++++
 site2/docs/security-oauth2.md     | 19 +++++++++++++++++++
 2 files changed, 38 insertions(+)

diff --git a/site2/docs/client-libraries-go.md 
b/site2/docs/client-libraries-go.md
index 90cd346..83f8930 100644
--- a/site2/docs/client-libraries-go.md
+++ b/site2/docs/client-libraries-go.md
@@ -658,3 +658,22 @@ opts := pulsar.ClientOptions{
     Authentication: NewAuthenticationTLS("my-cert.pem", "my-key.pem"),
 }
 ```
+
+## OAuth2 authentication
+
+To use [OAuth2 authentication](security-oauth2.md), you'll need to configure 
your client to perform the following operations.
+This example shows how to configure OAuth2 authentication.
+
+```go
+oauth := pulsar.NewAuthenticationOAuth2(map[string]string{
+               "type":       "client_credentials",
+               "issuerUrl":  "https://dev-kt-aa9ne.us.auth0.com/oauth/token";,
+               "audience":   "https://dev-kt-aa9ne.us.auth0.com/api/v2/";,
+               "privateKey": "/path/to/privateKey",
+               "clientId":   "0Xx...Yyxeny",
+       })
+client, err := pulsar.NewClient(pulsar.ClientOptions{
+               URL:              "puslar://my-cluster:6650",
+               Authentication:   oauth,
+})
+```
diff --git a/site2/docs/security-oauth2.md b/site2/docs/security-oauth2.md
index c847112..41b660f 100644
--- a/site2/docs/security-oauth2.md
+++ b/site2/docs/security-oauth2.md
@@ -113,3 +113,22 @@ config.setAuth(pulsar::AuthOauth2::create(params));
 
 pulsar::Client client("pulsar://broker.example.com:6650/", config);
 ```
+
+### Go client
+
+To enable OAuth2 authentication in Go client, you need to configure OAuth2 
authentication.
+This example shows how to configure OAuth2 authentication in Go client. 
+
+```go
+oauth := pulsar.NewAuthenticationOAuth2(map[string]string{
+               "type":       "client_credentials",
+               "issuerUrl":  "https://dev-kt-aa9ne.us.auth0.com/oauth/token";,
+               "audience":   "https://dev-kt-aa9ne.us.auth0.com/api/v2/";,
+               "privateKey": "/path/to/privateKey",
+               "clientId":   "0Xx...Yyxeny",
+       })
+client, err := pulsar.NewClient(pulsar.ClientOptions{
+               URL:              "puslar://my-cluster:6650",
+               Authentication:   oauth,
+})
+```

Reply via email to