Download Google doc file to device - android

I am trying to download a doc.google file to my device, however I can't figure the best way for that..
First: I created an Auth key to my Drive following this tutorial
Then: I am trying to follow this tutorial to download the file, but It is not going well
I want to connect to this Auth key through the app and download/Export the file automatically without prompting the user to choose account or anything..
This is the URL for the doc file:
https://docs.google.com/spreadsheets/d/1QJTna4iz-VivwAzwgq7V5QDs2XbgM2lEFPEG7NqCPdo/
Thanks in advance

Try the method used in this SO post.
It was cited that to overcome the google problem when setting the file publicly. As in the post:
If you set the file permissions to be publicly available and
create/generate a direct access link by using something like the
gdocs2direct tool or just crafting the link yourself:
https://docs.google.com/uc?export=download&id=<your file id>
You will get a cookie based verification code and prompt "Google could
not scan this file" prompt, which won't work for things such as
wget or Vagrantfile configs.
The code that it generates is a simple code that appends GET query
variable ...&confirm=### to the string, but it's per user specific,
so it's not like you can copy/paste that query variable for others.
The specified web page hosting method will suffice.

Related

Access to excel file via microsoft graph on android

I am trying to make an app for my organization which manages its onedrive files via an android app
I would like the manager of the app to maintain the app via a simple excel file which is located on my onedrive to which he will have write access and the rest of the users will have read access only. In other words, i need the app to be able to get the JSON representation of a selected excel file on my onedrive
i downloaded the "active-directory-android-native-v2-master" android sample and run it after obtaining an app ID and it worked correctly while getting the JSON response by executing the next MSGRAPH_URL constant
https://graph.microsoft.com/v1.0/me
Now, i guess that to get my excel JSON, i just need to modify the MSGRAPH_URL to the correct URL but i am getting very strange 404 errors when looking on the debug console (and the app seems to be stuck)
I tried modifying the app permissions via the microsoft app settings screen but with no success.
So the question is,
lets say the file i want to access is the one at the below link. What should be the correct MSGRAPH_URL constant and do i need to modify anything else? Also, is there a site or something that converts such a link to the correct graph.microsoft link?
excel file
According to your descriptions, I assume you want to get the excel file by the Graph API and then modify them.
We can use following steps:
We can modify the permissions at this site. According to this document, we should granted permission to 'Files.Read, Files.ReadWrite, Files.Read.All, Files.ReadWrite.All, Sites.Read.All, Sites.ReadWrite.All'.
Then use this API: 'https://graph.microsoft.com/v1.0/me/drive/root/children' to get the file on your OneDrive.
This API will return all the file on your OneDrive, you can find the excel file in the return. The result will be somthing like this:'
"id": "{The Id for the Excel File }",
"lastModifiedDateTime": "2018-09-03T06:05:59Z",
"name": "Book.xlsx",
"webUrl": "{The WebUrl for the Excel File }",
"cTag": "\"c:{94047B18-87D4-40A6-82C8-B0A0AE2344D5},9\"",
"size": 8252,
Now we can refer to this document to get the worksheet and use the following Docs to modify the Worksheet.

Firebase authentification works but I get error when using the Google Text to Speech API

I've set up a small android and firebase app... Authentification works like a charm, and in the firebase console, I can see my user, logged in with the Google account.
Now I am trying to experiment a little with the Text to Speech api, and in doing so, I followed this tutorial:
https://github.com/GoogleCloudPlatform/java-docs-samples/tree/master/texttospeech/cloud-client
I managed to make the small java app work, by setting the GOOGLE_APPLICATION_CREDENTIALS Environment variable (I followed this tutorial for this step: https://cloud.google.com/docs/authentication/getting-started), but I am not sure what I need to do to make that code work in the Android app where the users are authentificated..
The Error that I get when trying to make a call to the TextToSpeech API is:
The Application Default Credentials are not available. They are
available if running in Google Compute Engine. Otherwise, the
environment variable GOOGLE_APPLICATION_CREDENTIALS must be defined
pointing to a file defining the credentials. See
https://developers.google.com/accounts/docs/application-default-credentials
for more information.
The error mentioned comes from the line:
TextToSpeechClient textToSpeechClient = TextToSpeechClient.create();
This error appears because of the fact that on the android emulator I don't have access to the credentials that are set as environment variable in my OS..So I have to provide the credentials in another way.
In the case of other Google APIs, like Storage, I found out that this can be done like this:
// You can specify a credential file by providing a path to GoogleCredentials.
// Otherwise credentials are read from the GOOGLE_APPLICATION_CREDENTIALS environment variable.
GoogleCredentials credentials = GoogleCredentials.fromStream(new FileInputStream(jsonPath))
.createScoped(Lists.newArrayList("https://www.googleapis.com/auth/cloud-platform"));
Storage storage = StorageOptions.newBuilder().setCredentials(credentials).build().getService();
I managed to create the GoogleCredentials object with the contents of the json file, however the TextToSpeech client doesn't seem to provide a functionality similar to this:
StorageOptions.newBuilder().setCredentials(credentials).build()
So my question is....is there a way to provide the Credentials object to the TextToSpeech client?
Thanks
Currently, there is not a way to provide credentials to the TTS Client from this page.
Due to Security / Auth reasons, I believe the best suggested approach is to use Firebase Functions.
Get the Text
Call Firebase Functions
Have Firebase Functions call the TTS API
Return the results.
This way, no keys are leaked inside the application and you can use Firebase Auth.
Let me know if that helps!
Update:
Option 2: iOS Tutorial (should be adaptable to Android)
Get the Text
Call Firebase Functions
Have Firebase Functions return an OAuth2 Token
Use the token directly with the API

How to implement email adapter for Parse to allow password reset feature

Problem description
I am using AWS EC2 to host my bitnami parse server which acts as the backend for my android app. I am having trouble implementing password reset for the users of my app. I have followed the instructions from:
https://github.com/parse-community/parse-server#email-verification-and-password-reset
But I still get the error:
"com.parse.ParseRequest$ParseRequestException: An appName, publicServerURL, and emailAdapter are required for password reset and email verification functionality."
Step by step of what I did
I went to mailgun and created an account.
I registered a domain that I own (hosted by squarespace) to mailgun. (see picture below)
I went to my server.js file located in the apps/parse/htdocs folder.
I modified my server.js file to look like this, shown below.
Then in my android application, I called a test password reset using the following code.
Things I am unsure of
I haven't physically installed anything such as the simple-mailgun-adapter. I tried to follow this link: https://github.com/parse-community/parse-server-simple-mailgun-adapter. and install
npm install --save #parse/simple-mailgun-adapter to my apps/parse/htdocs folder. But I got a whole bunch of errors. Shown below.
I'm not sure what the publicServerURL is in the server.js file. I assumed it is the same thing as serverURL, so if you look at my server.js file, both serverURL and publicServerURL have the same input.
Please let me know if you guys can spot any errors I made. I've been working on this for a week, and still can't get password recovery working. Thank you!
A few things:
If your package.json has
"parse-server-simple-mailgun-adapter":"1.0.0",
under the dependencies section, then the package should be installed automatically. I usually check under the node_modules folder.
The resetPassword error is saying you are missing the appName parameter. You need to add it to your server config object:
var config = {
...
publicServerURL: (process.env.SERVER_URL || 'http://localhost:1337') + mountPath,
// Your apps name. This will appear in the subject and body of the emails that are sent.
appName: 'YOURAPPNAME',
...
Your publicServerURL is usually something like server.domain.com. It helps since people resetting their password will be redirected to a webpage on the domain where they will enter a new password. It's nice for users if the domain reflects something they can trust...
Hope this helps.
add {} in your package.json as it should not be empty.

Get file from Google Drive via shared link

I'm making something like online journal app, that will download "journal file" from Google Drive (via shared link) once and will update that file if it changes. Please, can anyone point me to some guides how to do it. I already tried to pin file from drive, but I don't really understand what to do next..
Downloading Files from Google Drive:
To download a Google Drive file via link, try this (from this tutorial):
https://drive.google.com/uc?export=download&id=FILE_ID
Just replace the FILE_ID with the original fileID found in the Drive URL.
Additonal notes:
You can download files using the DRIVE REST API
To download files, you make an authorized HTTP GET request to the file's resource URL and include the query parameter alt=media. For example:
GET https://www.googleapis.com/drive/v3/files/0B9jNhSvVjoIVM3dKcGRKRmVIOVU?alt=media
Authorization: Bearer ya29.AHESVbXTUv5mHMo3RYfmS1YJonjzzdTOFZwvyOAUVhrs
Downloading the file requires the user to have at least read access. Additionally, your app must be authorized with a scope that allows reading of file content. For example, an app using the drive.readonly.metadata scope would not be authorized to download the file contents. Users with edit permission may restrict downloading by read-only users by setting the viewersCanCopyContent field to true.
Updating files in Google Drive
Make an HTTP Request to Google Drive using PATCH. The PATCH method requests that a set of changes described in the request entity be applied to the resource identified by the Request- URI. Things to take note of are:
Parameters
Authorization
Request Body

http-link to private Dropbox files

i'm using the Dropbox Core Api for Android.
I want to generate a http-link to private files, so i can place it in text documents.
So the link opens the browser, which handles authentication.
if i browse the webinterface, i get a link like https://dl-web.dropbox.com/get/########?_subject_uid=#####&w=#############
Is there a way to do that with the Android Api?
Shared Links are no solution! (no /shares or /media )
Thanks...
No, the Dropbox API doesn't currently offer anything exactly like what you describe. If you need to access file content from your app, the best way to do so is using the /files (GET) API call, which returns the file data directly:
HTTP docs: https://www.dropbox.com/developers/core/docs#files-GET
Android docs: https://www.dropbox.com/static/developers/dropbox-android-sdk-1.6.2-docs/com/dropbox/client2/DropboxAPI.html#getFile(java.lang.String, java.lang.String, java.io.OutputStream, com.dropbox.client2.ProgressListener)
If you need a link to the data, the next best option is /media:
HTTP docs: https://www.dropbox.com/developers/core/docs#media
Android docs: https://www.dropbox.com/static/developers/dropbox-android-sdk-1.6.2-docs/com/dropbox/client2/DropboxAPI.html#media(java.lang.String, boolean)
The links returned by /media aren't share links, exactly, as they automatically expire after four hours and aren't listed on https://www.dropbox.com/links . Further, calling /media also doesn't automatically make the files non-private, as one would need the (reasonably unguessable) link to access it.

Categories

Resources