4

I am trying to upload data to google cloud storage using rest api According to the documentations we can use this api to send data to cloud store

https://www.googleapis.com/upload/storage/v1/b/[Bucket name]/o?uploadType=media&name=[object name]

and sending auth,content-type and content-length as header

auth can be genereted using service accounts which i generated but still unable to upload the file

i am getting this error

{
    "error": {
        "errors": [
            {
                "domain": "global",
                "reason": "authError",
                "message": "Invalid Credentials",
                "locationType": "header",
                "location": "Authorization"
            }
        ],
        "code": 401,
        "message": "Invalid Credentials"
    }
}
Tks
  • 129
  • 1
  • 6
  • did you find out since? been two day trying to find which token to pass to make it work. also wondering if the file will be public or private upon upload. – Nicolas Manzini Dec 20 '17 at 09:00
  • @NicolasManzini i wanted to use this code in android.. so i found out java code using google auth to do it.. if you want to do it using rest api see outh2.0 playground – Tushar Saha Dec 21 '17 at 09:50

1 Answers1

1

one of the correct way to do it would be

https://www.googleapis.com/upload/storage/v1/b/[bucket_name]/o?key={your_key}&uploadType=media&name=happy3

you can generate key from api screen in google console

other way is to go to outh2.0 playground and send request from there it will generate header files accordingly

Tushar Saha
  • 1,978
  • 24
  • 29