I’m working on implementing the Java DrEdit sample app on Google App Engine following the official documentation. The setup process went smoothly and I can successfully create new dredit documents. The OAuth authorization flow also works correctly and I can access the main application interface.
However, I’m encountering a persistent 401 error whenever the app tries to communicate with Google Drive API. Here’s the error I’m seeing in my GAE logs:
I followed most of the setup instructions exactly, though I had to include additional JAR files from the lib/dependencies folder in my Eclipse build path to resolve compilation issues. Just adding the war/WEB-INF/lib directory wasn’t sufficient.
What could be causing this authorization error even after successful OAuth?
Had the same issue with DrEdit on GAE. The credential store wasn’t persisting between requests - turns out my tokens were only saved in memory, not the datastore. GAE instances can die unexpectedly, so you lose everything stored in memory. Double-check that your service account key is properly set up in app.yaml and loads correctly when your servlet starts. OAuth might work fine, but if tokens aren’t stored persistently, you’ll get 401 errors on every API call after that.
Check your credential flow implementation - the DrEdit sample uses a custom CredentialStore that needs proper setup. I hit this exact same issue. My app wasn’t linking stored credentials to the current user session correctly. OAuth works fine, but then your servlet can’t grab the right access token for API calls. Make sure your CredentialMediator class maps user IDs to stored credentials properly, and verify the credential store actually writes to GAE datastore instead of just using local memory. Also check that your web.xml servlet mappings match what the sample expects exactly.
sounds like ur oauth token might not be refreshing right. try saving the refresh token in your session. also, make sure ur oauth scopes are lined up with what drive api needs – that’s a common cause for 401 errors.