Hello Juan, maybe with an example is more clear:

            URI keyURL;
            String fileName = "google_bigq.p12";
            keyURL =
BigQueryAPIManager.class.getClassLoader().getResource(fileName).toURI();

            GoogleCredential credential = new
GoogleCredential.Builder().setTransport(TRANSPORT)
                    .setJsonFactory(JSON_FACTORY)
                    .setServiceAccountId(EMAIL_ID)
                    .setServiceAccountScopes(SCOPES)
                    .setServiceAccountPrivateKeyFromP12File(new
File(keyURL))
                    .build();

Regards,
Alejandro




Alejandro González Rodrigo
*www.nextinit.com* <https://www.nextinit.com/>
*alejandro.gonza...@nextinit.com <alejandro.gonza...@nextinit.com>*
*+34  666 57 79 13*


2014/1/22 Juan de Dios Becerra <j.becerra4...@gmail.com>

> What you mean when say "then read file normally" is that I can use the
> same new ava.io.File(filePath) function?
>
> I guess this line:
>
> *InputStream stream = this.getServletContext().getResourceAsStream(path);*
>
> is only to collect the inputsream that you refer, but I don't use *stream
> *variable?
>
> El martes, 21 de enero de 2014 22:39:14 UTC-6, Vinny P escribió:
>>
>> On Tue, Jan 21, 2014 at 3:55 PM, Juan de Dios Becerra <j.bece...@gmail.
>> com> wrote:
>>
>> I am trying to use Google + Domains API in GAE, but when I try to create
>>> a GoogleCredential I need to use this:
>>>
>>> .setServiceAccountPrivateKeyFromP12File(new java.io.File(filePath))
>>>
>>> Where filePath is a .p12 extension file(private key for authentication)
>>> this file I put in WEB-INF folder and I granted permissions to all, but
>>> when I try to create the GoogleCredential I get this error:
>>>
>>> java.security.AccessControlException: access denied
>>> (java.io.FilePermission /WEB-INF/file.p12 read)
>>>
>>> Obviously the file has the correct name in my folder, this process works
>>> in my project which is not AppEngine, so I guess is a problem in the way to
>>> access files in AppEngine using java.io.File.
>>>
>>
>>
>>
>> Java I/O classes, such as File, are limited on App Engine. Try using
>> ServletContext's stream services to collect an inputstream, then read the
>> file normally. For example:
>>
>> *InputStream stream = this.getServletContext().getResourceAsStream(path);*
>>
>>
>> -----------------
>> -Vinny P
>> Technology & Media Advisor
>> Chicago, IL
>>
>> App Engine Code Samples: http://www.learntogoogleit.com
>>
>>  --
> You received this message because you are subscribed to the Google Groups
> "Google App Engine" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to google-appengine+unsubscr...@googlegroups.com.
> To post to this group, send email to google-appengine@googlegroups.com.
> Visit this group at http://groups.google.com/group/google-appengine.
> For more options, visit https://groups.google.com/groups/opt_out.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to google-appengine+unsubscr...@googlegroups.com.
To post to this group, send email to google-appengine@googlegroups.com.
Visit this group at http://groups.google.com/group/google-appengine.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to