Auth0 Home Blog Docs

Using Auth0 to get text (.txt) file content from Google Drive

auth0
api

#1

Hi,

I followed a tutorial here:

I am testing Alexa skill and wish to use account linking to Google Drive using Auth0. What should be done in order to get a text (.txt) file content from Google Drive?

I was able to get the authorization token, but have no idea how to get the text file from Google Drive.

Thanks.


#3

Once you’ve received the authorization token, all activities would be then controlled by your interaction with Google Drive. We don’t have any control over the Google Drive API or how to interact with it.

A good starting point for you though would be the Google Drive API File reference found at https://developers.google.com/drive/api/v3/reference/files


#4

Hello,

My case was that i was able to get the token, but when using the Google Drive API, the https GET response was a “return code: 401” error, which is an unauthorized error. It seems that Google Drive cannot authorize the Auth0 domain. How to make Google Drive to authorize Auth0 domain?

Here was the code i tested according the the tutorial for reference

let token = this.getAccessToken();
let options = {
method: ‘GET’,
// url: ‘https://jovotest.auth0.com/userinfo/’, // You can find your URL on Client --> Settings -->
// Advanced Settings --> Endpoints --> OAuth User Info URL

url: 'https://www.googleapis.com/drive/v2/files', 	// wish to list the files in the google drive account, and if my target file exist, 
													// the next step will wish to use the following Google Drive API:
													// url: 'https://www.googleapis.com/drive/v2/files/fileId',


headers:{
    authorization: 'Bearer ' + token,
}

};

// API request
request(options,(error, response, body) => {
if (!error && response.statusCode === 200){

    let data = JSON.parse(body); //Store the data we got from the API request
    console.log(data);
    /*
    To see how the user data was stored,
    go to Auth -> Users -> Click on the user you authenticated earlier -> Raw JSON
    */
    this.tell('Hi, ' + data.given_name);
} else {
    this.tell('Error');
}

}


#5

I don’t believe this is anything that we can assist with as it would seem to be something related to the code and process you’re using / testing which comes from another vendor / site. I suggest reaching out to them.