0

I made a script that downloads several files located in my professional OneDrive. This script works perfectly from a French computer, a US computer but it can't work from a Japanese computer.

To permit you understand the problem, I will detail the program:

1- I establish the token system (I got inspired by Jay Lee detailed answer) and retrieve the token in the access_token variable.

2- To download the file, in my case I cannot use

curl -w %{time_total} https://graph.microsoft.com/v1.0/me/drive/items/01M...WU/content -H "Authorization: Bearer $access_token"

Thus, this how I proceed:

#I get the item properties
itemProperties=$(curl ${ODf1Mb} -H "Authorization: Bearer $access_token")

#In these properties I select the downloadUrl that will permit me to download the file
downloadUrl=$(echo -e "$itemProperties" | grep "@microsoft.graph.downloadUrl" | awk -F'[",]' '{ print $9 }')    

#Finally I execute this URL storing the download time in a variable (I do all this stuff for this)
dload=$(curl -w %{time_total} ${downloadUrl} -H "Authorization: Bearer $access_token")

As I said at the begin, for French and US computers it will work but on the Japanese machine it doesn't. I do get the itemProperties and the downloadUrl but when I call the downloadUrl with CURL it seems that it cannot reach the server because I have this:

enter image description here

As we can see we do not even have the Total weight to be downloaded. As an element of comparison, this is the result in a French machine:

enter image description here

I know, there is a warning relating to command substitution but I haven't tried to fix it yet because it makes its job.

Note -> the downloadUrl has this format:

https://lpl-my.sharepoint.com/personal/{user}_{company infra domain}_com/_layouts/15/download.aspx?

I just cannot figure out what is the problem. I can access to the https://lpl-my.sharepoint.com through the browser so I don't think the server IP is banned.

Community
  • 1
  • 1
Héloïse Chauvel
  • 502
  • 3
  • 6
  • 21
  • I have still not found an explanation. But I guess it is a proxy issue. Maybe it is not possible to access some websites from command line for security reasons. So I tried to define the proxy in the terminal but it didn't work either... – Héloïse Chauvel Jun 08 '17 at 15:08

1 Answers1

0

Check your ping / traceroute to see if lpl-my.sharepoint.com resolves to the same network location.

Also, I have seen other folks run curl with -v to see verbose traces and see if what the difference is.

John
  • 1
  • I had already tested to ping lpl-my.sharepoint.com and I got this: `Reply from x.x.10.31: Destination host unreachable`. As the two 'x' are the same digits of my machine IP address (my machinne has x.x.22.10) I guess it is a server from the same network. But what is its function? DNS? – Héloïse Chauvel May 15 '17 at 07:56