williamnoble / go-mongo-grpc-auth

Go with gRPC Auth and MongoDB

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Google gRPC with MongoDB and simple JWT Authentication


How to setup protocol buffers and gRPC

I include detailed information as this is something I struggled with when I first encountered protocol buffers!

Within the root directory i.e. gprc-auth-mongo

# Generate the Proto file alone
$ protoc --go_out=. proto/services.proto

# Generate the GRPC file
$ protoc --go_out=. --go-grpc_out=. proto/services.proto

Within the .proto file itself, we set the package and optional go_package

// services.proto
option go_package = "./proto" // ignore the error
package proto

How to run this example

Server
$ go run server/main.go
Client
$ go run client/main.go

The client will output two JWT tokens [AuthResponse]

  • for when the User registers
  • for when the User logs in.

About

Go with gRPC Auth and MongoDB


Languages

Language:Go 100.0%