|
|
|
@ -116,3 +116,24 @@ stub = Helloworld::Greeter::Stub.new('localhost:50051', |
|
|
|
|
creds: creds, |
|
|
|
|
update_metadata: authorization.updater_proc) |
|
|
|
|
``` |
|
|
|
|
|
|
|
|
|
###Authenticating with Google (Node.js) |
|
|
|
|
|
|
|
|
|
```node |
|
|
|
|
// Base case - No encryption/authorization |
|
|
|
|
var stub = new helloworld.Greeter('localhost:50051'); |
|
|
|
|
... |
|
|
|
|
// Authenticating with Google |
|
|
|
|
var GoogleAuth = require('google-auth-library'); // from https://www.npmjs.com/package/google-auth-library |
|
|
|
|
... |
|
|
|
|
var creds = grpc.Credentials.createSsl(load_certs); // load_certs typically loads a CA roots file |
|
|
|
|
var scope = 'https://www.googleapis.com/auth/grpc-testing'; |
|
|
|
|
(new GoogleAuth()).getApplicationDefault(function(err, auth) { |
|
|
|
|
if (auth.createScopeRequired()) { |
|
|
|
|
auth = auth.createScoped(scope); |
|
|
|
|
} |
|
|
|
|
var stub = new helloworld.Greeter('localhost:50051', |
|
|
|
|
{credentials: creds}, |
|
|
|
|
grpc.getGoogleAuthDelegate(auth)); |
|
|
|
|
}); |
|
|
|
|
``` |
|
|
|
|