Skip to content

Authorization: Bearer your_auth_token (how to get auth_token) #818

Description

@navicore

question: will the API give me the bearer token it is using?

I'm able to create signed urls with gcloud-node but I'm trying to follow the resumable download docs. they suggest starting an upload on the server and passing the session to the client. looks easy except for the header:

Authorization: Bearer your_auth_token

can i do something like gcs.getAuth after some kind of init?

thx for any help.

Activity

  1. stephenplusplus commented on Aug 24, 2015

    @stephenplusplus
    Contributor

    We don't have this officially supported, but there's an opening if you go through some private properties.

    With your Storage instance, try:

    var reqOpts = { uri: '...' }; // what you would pass to the request module
    
    storage.makeAuthorizedRequest_(reqOpts, {
      onAuthorized: function(err, authorizedReqOpts) {
        // authorizedReqOpts.headers.Authorization = 'bearer token'
      }
    });

    I also made a module for exactly this which uses the same authorization settings as this library: https://github.com/stephenplusplus/google-auto-auth

    I think our library could eventually add support for just starting a resumable upload, handing off the responsibility to the user to see it through. We currently support resumable uploads, but wrap the whole thing and hide away the details.

  2. jgeewax commented on Aug 24, 2015

    @jgeewax
    Contributor
  3. stephenplusplus commented on Aug 24, 2015

    @stephenplusplus
    Contributor

    Sure, new ticket it is. Thanks for bringing this issue up, @navicore!

  4. added
    type: questionRequest for information or clarification. Not an issue.
    api: storageIssues related to the Cloud Storage API.
    on Aug 24, 2015
  5. navicore commented on Aug 24, 2015

    @navicore
    Author

    awesome help, thanks!

  6. stephenplusplus commented on Aug 31, 2015

    @stephenplusplus
    Contributor

    @navicore Since this issue, I moved all of our resumable logic into gcs-resumable-upload. You can use it to just get a resumable URI:

    var upload = require('gcs-resumable-upload');
    upload.createURI({
      bucket: 'bucket-name',
      file: 'file-name',
      authConfig: {
        // how you normally auth to gcloud, ex:
        keyFilename: 'keyfile.json'
      }
    }, function (err, uri) {});
  7. gotmikhail commented on Feb 1, 2016

    @gotmikhail

    Is there the option to set the origin with this method? We're trying to use our API to generate a resumable uri, but the client is running on a different subdomain.

  8. stephenplusplus commented on Feb 1, 2016

    @stephenplusplus
    Contributor

    I think @janesconference was going to help us implement that in gcs-resumable-upload. I opened an issue about it here: googleapis/gcs-resumable-upload#6. Feel free to subscribe to that one to track the progress.

  9. gotmikhail commented on Feb 1, 2016

    @gotmikhail

    @stephenplusplus Any other options? Ie., createWriteStream? Or, is it that setting the origin option isn't available right now at all?

  10. stephenplusplus commented on Feb 1, 2016

    @stephenplusplus
    Contributor

    I don't believe any other options exist, sadly. I'll work on adding support asap.

  11. 1 remaining item

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

api: storageIssues related to the Cloud Storage API.coretype: questionRequest for information or clarification. Not an issue.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions