Giter VIP home page Giter VIP logo

Comments (6)

easyCZ avatar easyCZ commented on July 29, 2024

Hey @joenayjoe ,

Could you please clarify the problem you are having? From what you mention, it does not look like a problem with grpc-web itself but rather how to perform user authentication with Github in Go.

Here are some resources that may help https://developer.github.com/v3/guides/getting-started/#authentication

I will close this issue as it does not appear to be directly related to grpc-web. If you feel this is not the case please feel free to comment below and we can take it from there.

from grpc-web.

joenayjoe avatar joenayjoe commented on July 29, 2024

Hi @easyCZ ,
Ok I will try to explain my problem. When a user clicks the link to log in with Github, he is redirected to Github authorization endpoint. Upon authorizing with user name and password, the user is redirected back to a callback URL How can I intercept that callback from grpc_web server to get the auth token? Since the callback is not a grpc method, I am not quite sure how to get the information from the callback.
May be I am messing up REST with gRPC.
Thanks

from grpc-web.

easyCZ avatar easyCZ commented on July 29, 2024

Thanks for clarification. Looking to give you an example now. Reopening

from grpc-web.

easyCZ avatar easyCZ commented on July 29, 2024

Hi @joenayjoe,

You can provide custom non-grpcweb functionality on the same server.
In the example you can provide a custom handler for any request that reaches the grpcweb server.

handler := func(resp http.ResponseWriter, req *http.Request) {
wrappedServer.ServeHTTP(resp, req)
}

For example, we can do the following, since we have access to the request:

handler := func(resp http.ResponseWriter, req *http.Request) {

		if req.URL.Path == "/auth" {
			fmt.Fprintf(resp, "Hi there, I love %s!", req.URL.Path[1:])
			return
		}
		wrappedServer.ServeHTTP(resp, req)
	}

This allows us to bypass the wrapped server and handle any request. You can get more fancy with this by using chi or echo. Let me know if that solves your problem

from grpc-web.

joenayjoe avatar joenayjoe commented on July 29, 2024

@easyCZ ,
Thank you for the tips. I tried to make a call to a custom URL and it indeed works.

from grpc-web.

easyCZ avatar easyCZ commented on July 29, 2024

@joenayjoe That's great news. Closing.

from grpc-web.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.