Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cant make signed url #877

Closed
stellanhaglund opened this issue Sep 21, 2015 · 8 comments
Closed

cant make signed url #877

stellanhaglund opened this issue Sep 21, 2015 · 8 comments
Assignees
Labels
core type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.

Comments

@stellanhaglund
Copy link

I get this

/home/server/node_modules/gcloud/node_modules/google-auto-auth/index.js:47
client.authorize(function (err) {
^
TypeError: undefined is not a function
at /home/server/node_modules/gcloud/node_modules/google-auto-auth/index.js:47:12
at addScope (/home/server/node_modules/gcloud/node_modules/google-auto-auth/index.js:113:5)
at callback (/home/server/node_modules/gcloud/node_modules/google-auto-auth/node_modules/goo
gle-auth-library/lib/auth/googleauth.js:41:5)
at /home/server/node_modules/gcloud/node_modules/google-auto-auth/node_modules/google-auth-l
ibrary/lib/auth/googleauth.js:124:9
at process._tickCallback (node.js:355:11)

when running this

app.get('/file/:fileId', function(req, res){

var remoteFile = bucket.file(req.params.fileId);

remoteFile.getSignedUrl({
    action: 'read',
    expires: '2025'
}, function(err, url) {
    if (err) {
        console.log('err');
        return;
    }

    console.log(url)

});

});
@stephenplusplus
Copy link
Contributor

Can you show where you gave auth configuration to gcloud?

@stellanhaglund
Copy link
Author

var projectId = 'idid'; // E.g. 'grape-spaceship-123'

var gcloud = require('gcloud')({
projectId: projectId
});

@stephenplusplus stephenplusplus added type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. core labels Sep 21, 2015
@stephenplusplus
Copy link
Contributor

Thanks, I was able to reproduce. Will keep you posted!

@stephenplusplus
Copy link
Contributor

I published a new version of google-auto-auth that will return a more helpful error. The problem here is in order to sign URLs, we need two properties that can't be detected in an auto-auth'd environment (like on GCE): client_email and private_key.

To enable this method to work, you'll have to authenticate with a keyfile (JSON, pem, or p12).

Related issue: #211

@andreasgrimm
Copy link

andreasgrimm commented Jun 29, 2016

I'm able to download a file with the .download() method, but using getSignedURL() results in the error

TypeError: bucket.file(...).getSignedURL is not a function

I'm using a firebase-storage bucket, I have a json key file including client_email and private_key.
Is this still a ACL / rights issue ?

Heres the relevant part of the stackstrace:

tryCatch (.../node_modules/regenerator-runtime/runtime.js:62:40)
    GeneratorFunctionPrototype.invoke [as _invoke] (.../node_modules/regenerator-runtime/runtime.js:336:22)
    GeneratorFunctionPrototype.prototype.(anonymous function) [as next] (.../node_modules/regenerator-runtime/runtime.js:95:21)

@stephenplusplus
Copy link
Contributor

Try calling getSignedUrl (note the casing). It probably should have been getSignedURL, shouldn't it have?

@stephenplusplus
Copy link
Contributor

No problem! Thanks for sending the edits in to those posts!

sofisl pushed a commit that referenced this issue Jan 17, 2023
This PR was generated using Autosynth. 🌈

Synth log will be available here:
https://source.cloud.google.com/results/invocations/2812cef8-9404-4275-bb51-8c6dafc1bc6f/targets

- [ ] To automatically regenerate this PR, check this box.

PiperOrigin-RevId: 361273630
Source-Link: googleapis/googleapis@5477122
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Projects
None yet
Development

No branches or pull requests

3 participants