Skip to content

Commit cf10e52

Browse files
committed
Merge pull request grpc#204 from jboeuf/auth_cpp_examples
Auth cpp examples
2 parents cd3c59a + 2da9eb9 commit cf10e52

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
_site/
2+
*.swp

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)