Unable to use remote api to access GAE datastore

478 views
Skip to first unread message

Manisha Awasthi

unread,
Dec 30, 2015, 7:55:33 AM12/30/15
to Google App Engine
Hi,

I have some code which was using clientLogin to access datastore with remote api. But , that method is going to be deprecated in January and suggests to use oauth2 credential with help of remoteapi.

Rempte Api has a method useServiceAccountCredential(ServiceAccount, P12). When I am using this method, I get below error: 

Error:
com.google.appengine.repackaged.com.google.api.client.http.HttpResponseException: 302 Found


I am unable to resolve this error. Can someone please help me?
Below is my maven dependency to access remote api
<dependency>
   
<groupId>com.google.appengine</groupId>
   
<artifactId>appengine-remote-api</artifactId>
   
<version>1.9.30</version>
</dependency>


Nick (Cloud Platform Support)

unread,
Dec 30, 2015, 7:29:29 PM12/30/15
to Google App Engine
It seems you're manually performing HTTP requests. If you look up "302 found" online, you'll find it's an HTTP response code sent to indicate that the next URL to request with the same data should be the one specified in the "Location" header of the response. Is that logic possible to include in your code? Can your HTTP library automatically follow 3xx redirects?

Moshe Shaham

unread,
Apr 13, 2016, 4:23:42 AM4/13/16
to Google App Engine
I'm also having this issue

Nick (Cloud Platform Support)

unread,
Apr 13, 2016, 1:42:04 PM4/13/16
to Google App Engine
Hey Moshe, 

Did you manage to take any action based on reading my prior comment?

Subharthi Chatterjee

unread,
Apr 16, 2016, 10:32:59 AM4/16/16
to Google App Engine
Hey Nick,
  Those Http libraries are internally used appengine, question is how do we bypass them and do it through simple http connection?

Nick (Cloud Platform Support)

unread,
Apr 18, 2016, 12:01:21 PM4/18/16
to Google App Engine
Hey Subharthi,

Do you have code which can reliably reproduce the issue? This is necessary to report an issue, and while the correct place to do so is the Public Issue Tracker, I'll be happy to take the report from this thread and create a Public Issue Tracker thread for you to follow once the behaviour has been successfully reproduced. 
 
So, feel free to post some code / a project archive which can reliably reproduce the issue, and I'll be happy to assist.

Best wishes,

Nick
Cloud Platform Community Support

Subharthi Chatterjee

unread,
Apr 19, 2016, 1:33:48 AM4/19/16
to Google App Engine
Hi Nick,

After downloading the p12 file, I was trying with this piece of code, to connect to remote_api, line 'remoteApiInstaller.install(remoteApiOptions);
' throws an 302 HttpResponseException

PrivateKey privateKey = null;
       
try {

             privateKey
= SecurityUtils.loadPrivateKeyFromKeyStore(SecurityUtils.getPkcs12KeyStore(),
                   
 
this.class.getClassLoader().getResourceAsStream("<APP_ID>-XXXXX.p12"),
 
"notasecret", "privatekey", "notasecret");

       
} catch (GeneralSecurityException e) {
            e
.printStackTrace();
       
} catch (IOException e) {
            e
.printStackTrace();
       
}
       
RemoteApiOptions remoteApiOptions = new RemoteApiOptions()
               
 
.server("<APP_ID>.appspot.com",
443).useServiceAccountCredential("<APP_ID>@appspot.gserviceaccount.com",
 privateKey
);
       
RemoteApiInstaller remoteApiInstaller = new RemoteApiInstaller();
       
try {
            remoteApiInstaller
.install(remoteApiOptions);
       
} catch (Exception ex) {
            logger
.error("Error occured..", ex);
       
}

Nick (Cloud Platform Support)

unread,
Apr 20, 2016, 3:50:12 PM4/20/16
to Google App Engine
Using the latest version of all relevant libraries, I'm not able to reproduce this behaviour. Could you check the .jar files on your classpath, or the dependencies in your pom.xml (if using maven) to see if they're all updated?

Regards,


Nick
Cloud Platform Community Support

Reply all
Reply to author
Forward
0 new messages