Skip to content

Commit c9bf8d0

Browse files
committed
Adding auth C++ examples.
Fixes the C++ part of grpc#181.
1 parent cd3c59a commit c9bf8d0

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

docs/guides/auth.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,33 @@ combined_creds = ssl_creds.compose(call_creds)
194194
stub = Helloworld::Greeter::Stub.new('greeter.googleapis.com', combined_creds)
195195
```
196196

197+
### C++
198+
199+
#### Base case - no encryption or authentication
200+
```cpp
201+
auto channel = grpc::CreateChannel("localhost:50051", InsecureChannelCredentials());
202+
std::unique_ptr<Greeter::Stub> stub(Greeter::NewStub(channel));
203+
...
204+
```
205+
206+
#### With server authentication SSL/TLS
207+
208+
```cpp
209+
auto channel_creds = grpc::SslCredentials(grpc::SslCredentialsOptions());
210+
auto channel = grpc::CreateChannel("myservice.example.com", creds);
211+
std::unique_ptr<Greeter::Stub> stub(Greeter::NewStub(channel));
212+
...
213+
```
214+
215+
#### Authenticate with Google using scopeless credentials
216+
217+
```cpp
218+
auto creds = grpc::GoogleDefaultCredentials();
219+
auto channel = grpc::CreateChannel("greeter.googleapis.com", creds);
220+
std::unique_ptr<Greeter::Stub> stub(Greeter::NewStub(channel));
221+
...
222+
```
223+
197224
### C&#35;
198225
199226
#### Base case - no encryption or authentication

0 commit comments

Comments
 (0)