Giter Club home page Giter Club logo

Comments (3)

x1ddos avatar x1ddos commented on August 18, 2024

Here's a much more juicy implementation: https://github.com/dhermes/go-endpoints/commit/b6a68e7fa38242803713676cb7c1101032e01db5

from go-endpoints.

x1ddos avatar x1ddos commented on August 18, 2024

Interesting. There's definitely something going on differently on production servers.

I've just updated https://go-endpoints.appspot.com to use endpoints.CurrentUser() with appropriate scopes and clientIDs:

instead of using appengine/user.CurrentOAuth() in GreetingService.Sign() method it now does this:

user, err := endpoints.CurrentUser(c, scopes, audiences, clientIds)
if err == nil {
    greet.Author = user.String()
} else {
    greet.Author = "Anonymous User (" + err.Error() + ")"
}

The interesting part is the following:

Try signing the guestbook using API explorer (don't forget to turn on "Authorize requests" switch to the right):
https://developers.google.com/apis-explorer/?base=https://go-endpoints.appspot.com/_ah/api#p/greeting/v1/greeting.greets.sign

What you'll see in the author field is Anonymous User (No request exists in the context.) which is failing exactly at this point:

req, ok := c.Request().(*http.Request)
if !ok {
    return nil, errors.New("No request exists in the context.")
}

(so, c.Request() is something else than http.Request in production)

Didn't really expect that but well, the docs did say "c.Request() is internal use only".

I can think about two solutions: (1) we'll have to use http.Request instead of Context here, or (2) @dhermes talks to App Engine - Go folks and try to uncover some truth / possible solutions :) though I suspect they'll say "use http.Request"

from go-endpoints.

x1ddos avatar x1ddos commented on August 18, 2024

Wow, I didn't know Github can cross-reference different repos.

Anyway, I updated go-endpoints guestbook demo and go-tictactoe repos to use latest changes from #12 (fix for c.Request().(*http.Request) not working in production) and integrated go-tictactoe/tictactoe package with go-endpoints demo so we can all play TicTacToe at https://go-endpoints.appspot.com/tictactoe now :)

from go-endpoints.

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.