cloudendpoints / endpoints-java

A Java framework for building RESTful APIs on Google App Engine
Apache License 2.0
32 stars 35 forks source link

Using Firebase Anonymous Auth Token to cloud endpoint returns 503 error #112

Open g-ericso opened 7 years ago

g-ericso commented 7 years ago

We are using the firebase auth token generated with an anonymous account. The cloud endpoints returns a 503 error.

com.google.api.server.spi.handlers.EndpointsMethodHandler$RestHandler handle: exception occurred while invoking backend method (EndpointsMethodHandler.java:124)
java.lang.NullPointerException
    at endpoints.repackaged.com.google.common.base.Preconditions.checkNotNull(Preconditions.java:212)
    at com.google.api.auth.UserInfo.<init>(UserInfo.java:46)
    at com.google.api.auth.Authenticator.toUserInfo(Authenticator.java:278)
    at com.google.api.auth.Authenticator.authenticate(Authenticator.java:109)
    at com.google.api.server.spi.auth.EspAuthenticator.authenticate(EspAuthenticator.java:83)
    at com.google.api.server.spi.request.Auth.authenticate(Auth.java:101)
    at com.google.api.server.spi.request.ServletRequestParamReader.getUser(ServletRequestParamReader.java:192)
    at com.google.api.server.spi.request.ServletRequestParamReader.deserializeParams(ServletRequestParamReader.java:137)
    at com.google.api.server.spi.request.RestServletRequestParamReader.read(RestServletRequestParamReader.java:124)
    at com.google.api.server.spi.SystemService.invokeServiceMethod(SystemService.java:349)
    at com.google.api.server.spi.handlers.EndpointsMethodHandler$RestHandler.handle(EndpointsMethodHandler.java:119)
    at com.google.api.server.spi.handlers.EndpointsMethodHandler$RestHandler.handle(EndpointsMethodHandler.java:102)
    at com.google.api.server.spi.dispatcher.PathDispatcher.dispatch(PathDispatcher.java:50)
    at com.google.api.server.spi.EndpointsServlet.service(EndpointsServlet.java:71)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
    at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:848)
    at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1772)
    at com.google.api.control.ControlFilter.doFilter(ControlFilter.java:296)
    at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1759)
    at com.google.api.control.ConfigFilter.doFilter(ConfigFilter.java:120)
    at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1759)
    at com.googlecode.objectify.ObjectifyFilter.doFilter(ObjectifyFilter.java:48)
    at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1759)
    at com.google.apphosting.utils.servlet.ParseBlobUploadFilter.doFilter(ParseBlobUploadFilter.java:125)
    at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1759)
    at com.google.apphosting.runtime.jetty9.SaveSessionFilter.doFilter(SaveSessionFilter.java:37)
    at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1759)
    at com.google.apphosting.utils.servlet.JdbcMySqlConnectionCleanupFilter.doFilter(JdbcMySqlConnectionCleanupFilter.java:60)
    at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1759)
    at com.google.apphosting.utils.servlet.TransactionCleanupFilter.doFilter(TransactionCleanupFilter.java:48)
    at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1759)
    at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:582)
    at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:143)
    at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:524)
    at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:226)
    at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1180)
    at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:512)
    at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:185)
    at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1112)
    at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141)
    at com.google.apphosting.runtime.jetty9.AppVersionHandlerMap.handle(AppVersionHandlerMap.java:297)
    at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:134)
    at org.eclipse.jetty.server.Server.handle(Server.java:534)
    at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:320)
    at com.google.apphosting.runtime.jetty9.RpcConnection.handle(RpcConnection.java:219)
    at com.google.apphosting.runtime.jetty9.RpcConnector.serviceRequest(RpcConnector.java:81)
    at com.google.apphosting.runtime.jetty9.JettyServletEngineAdapter.serviceRequest(JettyServletEngineAdapter.java:108)
    at com.google.apphosting.runtime.JavaRuntime$RequestRunnable.dispatchServletRequest(JavaRuntime.java:650)
    at com.google.apphosting.runtime.JavaRuntime$RequestRunnable.dispatchRequest(JavaRuntime.java:612)
    at com.google.apphosting.runtime.JavaRuntime$RequestRunnable.run(JavaRuntime.java:582)
    at com.google.apphosting.runtime.JavaRuntime$NullSandboxRequestRunnable.run(JavaRuntime.java:776)
    at com.google.apphosting.runtime.ThreadGroupPool$PoolEntry.run(ThreadGroupPool.java:263)
    at java.lang.Thread.run(Thread.java:745)

As I remembered, this may relate to email address is not found in that User object which is valid in anonymous user. It will be great to return a User object with user id from firebase with empty or null value in email field.

ryzhovdv commented 5 years ago

Hello @g-ericso ! Have this issue been solved for today? I have faced the same problem..

g-ericso commented 5 years ago

Yes. it was fixed that last year. I don't remember exactly which field is causing the NULL pointer exception. However, it is a problem due to either username or email address was NULL for anonymous user. I thought a fix was applied. Let me figure it out more.

ryzhovdv commented 5 years ago

Thanks @g-ericso ! If it is applied, how to avoid this error?

g-ericso commented 5 years ago

@ryzhovdv I sent a message to our Googler. I will keep you posted when there is an update.

ryzhovdv commented 5 years ago

Thank you!

On Mon, Aug 26, 2019 at 7:56 PM Eric So notifications@github.com wrote:

@ryzhovdv https://github.com/ryzhovdv I sent a message to our Googler. I will keep you posted when there is an update.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/cloudendpoints/endpoints-java/issues/112?email_source=notifications&email_token=ACE7RYEUCNECSTWYHO6ZGLTQGQDNRA5CNFSM4D67GLU2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD5E7AMQ#issuecomment-524939314, or mute the thread https://github.com/notifications/unsubscribe-auth/ACE7RYBZ5K5YIRG2OGEX6G3QGQDNRANCNFSM4D67GLUQ .

g-ericso commented 5 years ago

Can you please give us more details or trace logs?

This bug was fixed in endpoints-management-java release 1.0.11. Please make sure the customer's pom file includes the correct dependency version (https://cloud.google.com/endpoints/docs/frameworks/java/adding-api-management)

com.google.endpoints endpoints-management-control-appengine-all 1.0.11

Hope it helps,

ryzhovdv commented 5 years ago

Good day! When I changed endpoints-management-java version to the latest -1.0.11 the error have gone! Thanks! But the user argument at endpoint method is null when i get token for anonymous user on android app. When i get token for google account user on android app everything works! At firebase console Anonymous login is allowed and I see anonymous users and it's ids. Why it is not the case at appengine - don't know..

On Tue, Aug 27, 2019 at 3:18 AM Eric So notifications@github.com wrote:

Can you please give us more details or trace logs?

This bug was fixed in endpoints-management-java release 1.0.11. Please make sure the customer's pom file includes the correct dependency version ( https://cloud.google.com/endpoints/docs/frameworks/java/adding-api-management ) com.google.endpoints endpoints-management-control-appengine-all 1.0.11

Hope it helps,

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/cloudendpoints/endpoints-java/issues/112?email_source=notifications&email_token=ACE7RYDG244TBOA62R5W7DDQGRXETA5CNFSM4D67GLU2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD5GCBGQ#issuecomment-525082778, or mute the thread https://github.com/notifications/unsubscribe-auth/ACE7RYBAMPXEPFF3ZB7G3RDQGRXETANCNFSM4D67GLUQ .