The auth_creds prints before the metadata because the callback is called
each time you initiate a request, and it is not called immediately.

On Tue, May 23, 2017 at 12:01 PM <[email protected]> wrote:

>
>
> Thanks Michael Lumish. Can you please confirm whether the below code is
> correct. I am worried whether there is some asynchronous problem. How to
> use auth_creds for the next function - 
> grpc.credentials.combineChannelCredentials(ssl_creds,
> auth_creds) ?
>
> function generateMetadata(params, callback) {
>    var metadata = new grpc.Metadata();
>    metadata.add('authorization', response.access_token);
>    console.log(metadata); // *Prints second*
>    callback(null,metadata);
> }
>
> var auth_creds =
> grpc.credentials.createFromMetadataGenerator(generateMetadata);
> console.log(auth_creds); // *Prints first*
> var combined_creds = grpc.credentials.combineChannelCredentials(ssl_creds,
> auth_creds);
> var clientnew = new proto.Gateway('localhost:50001',combined_creds);
> var cmd = {};
> var call = clientnew.listAcousticSystems(cmd);
> call.on('data', function(systems) {
>    console.log(systems);
> });
>
>
>
> On Tuesday, May 23, 2017 at 3:36:18 PM UTC-3, Michael Lumish wrote:
>>
>> You got an error that says "Invalid Authorization Token". That error was
>> thrown by the call's "error" event handler, which means that that the call
>> ended with that error. That error message probably came from the server.
>> So, there is some problem with your access_token.
>>
> --
> 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/26ecaeea-e835-4516-875f-1c4d0af1a991%40googlegroups.com
> <https://groups.google.com/d/msgid/grpc-io/26ecaeea-e835-4516-875f-1c4d0af1a991%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-4ci9qY4_2uLDz38wqDni%2BJ%3D%3DBs8qj%2BCpx4S4GH6g%3DiN2g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Attachment: smime.p7s
Description: S/MIME Cryptographic Signature

Reply via email to