0
votes

I want to upload a csv file to fusion table using curl. I created client id and secret using developer console. Then I generated access token using google playground link.

using the generated access token, I could successfully import data in fusion table from csv file.

Now, the problem is that the access token expired after some time and I have to get new access token using refresh token. This I want to do also using curl, but I get 'unauthorized_client' error while refreshing the access token.

following are the commands used by me.

to upload data in fusion table

curl -s -S --data-binary "INPUT_CSV_FILE" -H "Authorization: Bearer ACCESS_TOKEN_FROM_PLAYGROUNDLINK " -H "Content-Type: application/octet-stream" "https://www.googleapis.com/upload/fusiontables/v1/tables/FUSION_TABLE_ID/import"

Refresh token

curl https://www.googleapis.com/oauth2/v3/token -d "grant_type=refresh_token&refresh_token=REFRESH_TOKEN(from playground)&client_id=CLIENT_ID&client_secret=CLIENT_SECRET" -X POST

1
based on the "unauthorized client" message, I would try adding -A "Mozilla" into your cmd-line, before the -d .. Good luck.shellter
Thankfully, I have reached the solution for problem. I was generating Authentication code in Google playground, but it was not using the client Id that i generated. Then I generated authentification code with my own http request as follows accounts.google.com/o/oauth2/auth? redirect_uri=REDIRECT_URL& response_type=code& client_id=CLIENT_ID& scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Ffusiontables& approval_prompt=force& access_type=offline and used authentication code to generate access token & it worked. Hope this helps someone else too. Thanks #shellter for your help!Gurpreet
post your solution as an answer below. Then you can accept your own answer after 48 hrs (or something like that) and gain reputation points. Use the {} tool at top left of edit box after selecting text to give it the correct "code" format. Glad you found a solution. Good luck.shellter

1 Answers

0
votes

I generated authentification code with my own http request as follows accounts.google.com/o/oauth2/auth? redirect_uri=REDIRECT_URL& response_type=code& client_id=CLIENT_ID& scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Ffusiontables& approval_prompt=force& access_type=offline and used authentication code to generate access token & it worked.