Hi all,
I'm using latest version of gRPC and I'm using node.js to make an authenticated channel using custom access token and ssl certificate
I was trying to make authenticated channel using combined credentials (ie. ssl_creds & call_creds) as shown in http://www.grpc.io/docs/guides/auth.html#authenticate-with-google-4.
But instead of using google auth, I was trying to use my own access token.
I am getting errors such as
W20170523-10:25:15.721(-3)? (STDERR) plainSignature.push( signature[key].name );
W20170523-10:25:15.720(-3)? (STDERR) ^
W20170523-10:25:15.728(-3)? (STDERR) TypeError: Cannot read property 'name' of null
W20170523-10:25:15.733(-3)? (STDERR) at __ (C:\Users\prasanna.elangovan\Desktop\Meteor_Practice\node_modules\arguejs\argue.js:117:46)
Can anyone please provide example code to achieve a authenticated channel using ssl certificate & custom access token
FYI - There is a way to do this in python - http://www.grpc.io/grpc/python/_modules/grpc.html#access_token_call_credentials. I want to do the same in node.js.
Thanks in advance.
--
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 grpc-io+u...@googlegroups.com.
To post to this group, send email to grp...@googlegroups.com.
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/136526ce-dc63-4faa-986b-0568764ab0a4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
W20170523-13:20:15.298(-3)? (STDERR) C:\Users\xxxxxxxx\Desktop\Meteor_Practice\node_modules\grpc\src\node\src\credentials.js:100W20170523-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 functionW20170523-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
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 grpc-io+u...@googlegroups.com.
To post to this group, send email to grp...@googlegroups.com.
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.
function generateMetadata(params, callback) {var metadata = new grpc.Metadata();
metadata.add('authorization', response.access_token);console.log(metadata);callback(null,metadata);}var auth_creds = grpc.credentials.createFromMetadataGenerator(generateMetadata);
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.listAcousticSystems(cmd);
call.on('data', function(systems) {console.log(systems);});
I20170523-15:18:27.515(-3)? CallCredentials {}I20170523-15:18:27.532(-3)? Metadata {I20170523-15:18:27.534(-3)? _internal_repr: { authorization: [ 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJ2ZW1jby5pbyIsImF1ZCI6InZlbWNvLmlvIiwic3ViIjoiMTFkZWVmMDUtOWUzNy00ZDQxLWJmNjgtZTE0MTQwY2IxODJmIiwiaWF0IjoxNDk1NTYzNTA3LCJleHAiOjE0OTU1NjQ0MDcsInVzZXJfbmFtZSI6InVzZXIxIn0.nLOa2c1PWWL59AIaiZjpzT_p0wSeUIoOsxsUHarTWCE' ] } }W20170523-15:18:27.574(-3)? (STDERR) events.js:141W20170523-15:18:27.575(-3)? (STDERR) throw er; // Unhandled 'error' eventW20170523-15:18:27.582(-3)? (STDERR) ^W20170523-15:18:27.583(-3)? (STDERR)W20170523-15:18:27.589(-3)? (STDERR) Error: Invalid Authorization TokenW20170523-15:18:27.590(-3)? (STDERR) at ClientReadableStream._emitStatusIfDone (C:\Users\prasanna.elangovan\Desktop\Meteor_Practice\node_modules\grpc\src\node\src\client.js:201:19)W20170523-15:18:27.598(-3)? (STDERR) at ClientReadableStream._receiveStatus (C:\Users\prasanna.elangovan\Desktop\Meteor_Practice\node_modules\grpc\src\node\src\client.js:180:8)W20170523-15:18:27.600(-3)? (STDERR) at C:\Users\prasanna.elangovan\Desktop\Meteor_Practice\node_modules\grpc\src\node\src\client.js:592:14=> Exited with code: 1--
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 grpc-io+u...@googlegroups.com.
To post to this group, send email to grp...@googlegroups.com.
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/150acf63-326d-432e-a0f9-403b8987c27a%40googlegroups.com.
ERROR:root:Exception iterating responses: Invalid token type. Token must be a <class 'bytes'>Traceback (most recent call last): File "C:\Users\prasanna.elangovan\AppData\Local\Programs\Python\Python36-32\lib\site-packages\grpc\_server.py", line 388, in _take_response_from_response_iterator return next(response_iterator), True File "C:\Users\prasanna.elangovan\Documents\io\src\test\gateway\main.py", line 124, in ListAcousticSystems user_uuid = extract_user_uuid_from_context(context) File "C:\Users\prasanna.elangovan\Documents\io\src\test\gateway\main.py", line 57, in extract_user_uuid_from_context valid_token = extract_access_token_from_context(context) File "C:\Users\prasanna.elangovan\Documents\io\src\test\gateway\main.py", line 52, in extract_access_token_from_context return decode_access_token(bearer_token) File "C:\Users\prasanna.elangovan\Documents\io\src\test\gateway\main.py", line 40, in decode_access_token leeway=datetime.timedelta(seconds=10) File "C:\Users\prasanna.elangovan\AppData\Local\Programs\Python\Python36-32\lib\site-packages\jwt\api_jwt.py", line 61, in decode payload, signing_input, header, signature = self._load(jwt) File "C:\Users\prasanna.elangovan\AppData\Local\Programs\Python\Python36-32\lib\site-packages\jwt\api_jws.py", line 150, in _load binary_type))jwt.exceptions.DecodeError: Invalid token type. Token must be a <class 'bytes'>
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 firstvar 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);});--
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 grpc-io+u...@googlegroups.com.
To post to this group, send email to grp...@googlegroups.com.
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.
metadata.add('authorization', response.access_token);
// I changed the above line as follows
metadata.add('authorization', 'Bearer '+response.access_token);