Hello All,

I have two django applications and I want to send a user object from one 
django application to other django application through gRPC. I have seen 
string and integer types working fine. Please find the code attached.



service Usermanagement {
  rpc UserLogin (UserRequest) returns (UserResponse) {}
}

// The request message containing the user's name.
message UserRequest {
  string username = 1;
  string password = 2;
}

// The response message containing the greetings
message UserResponse {
  string message = 1;
  string fullname = 2;
  string token = 4;
  int32 status = 5;
}

This is my Django application code.

import grpc

from userservice import userservices_pb2
from userservice import userservices_pb2_grpc
from usermanagement.models import AppUser as User
from django.contrib.auth import authenticate
from rest_framework.authtoken.models import Token
from google.protobuf import any_pb2

class Usermanagement(userservices_pb2_grpc.UsermanagementServicer):

    def UserLogin(self, request, context):
        User = authenticate(username=request.username, password=request.
password)
        if User is not None:
            (token, created) = Token.objects.get_or_create(user=User)
            User.authentication_token = token.key
            return userservices_pb2.UserResponse(message='success', status=0
, fullname=User.fullname, token = token.key)
        else:
            return userservices_pb2.UserResponse(message='Incorrect 
Username/Password', status=1)


Please anyone can help me "How can I include the User object or user list" 
in the return response.

-- 
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/f6718446-c8ac-4271-980a-31a92f6f67b8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to