The createFromMetadataGenerator function takes as its argument a function. The first argument to that function is an object, which currently just contains the key "service_url", which is probably not relevant to your use case. The second argument to that function is a callback, which has the standard arguments: the first is the error, and the second is the result. Based on that code, your metadata generator should look like this
function generateMetadata(params, callback) {
var metadata = new grpc.Metadata();
metadata.add('authorization', access_token);
callback(null, metadata);
}
Or, if you know the authorization header won't change, you can simply do
this instead:
var metadata = new grpc.Metadata();
metadata.add('authorization', access_token);
function generateMetadata(params, callback) {
callback(null, metadata);
}
On Tue, May 23, 2017 at 11:07 AM <[email protected]> wrote:
>
> Thanks Mr. Michael Lumish for your timely reply.
>
> Actually I think that error is because I was calling server-side streaming
> function as simple rpc function. So please ignore the previous error.
> But when I tried to call correctly I got the below error. I guess below
> error is caused because I'm not passing the correct parameters to
> grpc.credentials.createFromMetadataGenerator
> function
>
> W20170523-13:20:15.298(-3)? (STDERR)
> C:\Users\xxxxxxxx\Desktop\Meteor_Practice\node_modules\grpc\src\node\src\credentials.js:100
> W20170523-13:20:15.300(-3)? (STDERR) metadata_generator({service_url:
> service_url}, function(error, metadata) {
> W20170523-13:20:15.301(-3)? (STDERR) ^
> W20170523-13:20:15.311(-3)? (STDERR) TypeError: metadata_generator is not
> a function
> W20170523-13:20:15.317(-3)? (STDERR) at
> C:\Users\xxxxxx\Desktop\Meteor_Practice\node_modules\grpc\src\node\src\credentials.js:100:5
> => Exited with code: 1
>
>
> Below given is my program. I just wanted to know what is the input
> parameter for grpc.credentials.createFromMetadataGenerator function.
> Whether the parameter is metadata or access token?
> Can you please explain me how to process the access token before passing
> it to grpc.credentials.createFromMetadataGenerator function.
>
> var metadata = new grpc.Metadata();
> metadata.add('authorization', access_token);
> console.log(metadata);
> var auth_creds = grpc.credentials.createFromMetadataGenerator(metadata);
> console.log(auth_creds);
> var combined_creds = grpc.credentials.combineChannelCredentials(ssl_creds,
> auth_creds);
> var clientnew = new proto.Gateway('localhost:50001',combined_creds);
> var cmd = {};
> var call = clientnew.somefunction(cmd);
> call.on('data', function(systems) {
> console.log(systems);
> });
>
>
> --
> You received this message because you are subscribed to the Google Groups "
> grpc.io" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at https://groups.google.com/group/grpc-io.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/grpc-io/bd471b80-f020-4542-a07a-0e2ac2449729%40googlegroups.com
> <https://groups.google.com/d/msgid/grpc-io/bd471b80-f020-4542-a07a-0e2ac2449729%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>
--
You received this message because you are subscribed to the Google Groups
"grpc.io" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/grpc-io.
To view this discussion on the web visit
https://groups.google.com/d/msgid/grpc-io/CAPK2-4dVAO7nkgjVzgORzMK8xK%3DBPxp4SHBFaFG%3Dn%3D26jtySeg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
smime.p7s
Description: S/MIME Cryptographic Signature
