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

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

Closed
navicore opened this issue Aug 23, 2015 · 9 comments
Closed

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

navicore opened this issue Aug 23, 2015 · 9 comments
Assignees
Labels
api: storage Issues related to the Cloud Storage API. core type: question Request for information or clarification. Not an issue.

Comments

@navicore
Copy link

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.

@stephenplusplus
Copy link
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.

@jgeewax
Copy link
Contributor

jgeewax commented Aug 24, 2015 via email

@stephenplusplus
Copy link
Contributor

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

@stephenplusplus stephenplusplus added type: question Request for information or clarification. Not an issue. api: storage Issues related to the Cloud Storage API. core labels Aug 24, 2015
@navicore
Copy link
Author

awesome help, thanks!

@stephenplusplus
Copy link
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) {});

@gotmikhail
Copy link

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.

@stephenplusplus
Copy link
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.

@gotmikhail
Copy link

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

@stephenplusplus
Copy link
Contributor

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

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/7a1b0b96-8ddb-4836-a1a2-d2f73b7e6ffe/targets

- [ ] To automatically regenerate this PR, check this box.
sofisl pushed a commit that referenced this issue Jan 24, 2023
[![WhiteSource Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
| [sinon](https://sinonjs.org/) ([source](https://togithub.com/sinonjs/sinon)) | [`^11.0.0` -> `^12.0.0`](https://renovatebot.com/diffs/npm/sinon/11.1.2/12.0.1) | [![age](https://badges.renovateapi.com/packages/npm/sinon/12.0.1/age-slim)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://badges.renovateapi.com/packages/npm/sinon/12.0.1/adoption-slim)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://badges.renovateapi.com/packages/npm/sinon/12.0.1/compatibility-slim/11.1.2)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://badges.renovateapi.com/packages/npm/sinon/12.0.1/confidence-slim/11.1.2)](https://docs.renovatebot.com/merge-confidence/) |

---

### Release Notes

<details>
<summary>sinonjs/sinon</summary>

### [`v12.0.1`](https://togithub.com/sinonjs/sinon/blob/master/CHANGES.md#&#8203;1201)

[Compare Source](https://togithub.com/sinonjs/sinon/compare/v12.0.0...v12.0.1)

-   [`3f598221`](https://togithub.com/sinonjs/sinon/commit/3f598221045904681f2b3b3ba1df617ed5e230e3)
    Fix issue with npm unlink for npm version > 6 (Carl-Erik Kopseng)
    > 'npm unlink' would implicitly unlink the current dir
    > until version 7, which requires an argument
-   [`51417a38`](https://togithub.com/sinonjs/sinon/commit/51417a38111eeeb7cd14338bfb762cc2df487e1b)
    Fix bundling of cjs module ([#&#8203;2412](https://togithub.com/sinonjs/sinon/issues/2412)) (Julian Grinblat)
    > -   Fix bundling of cjs module
    >
    > -   Run prettier

*Released by [Carl-Erik Kopseng](https://togithub.com/fatso83) on 2021-11-04.*

#### 12.0.0

### [`v12.0.0`](https://togithub.com/sinonjs/sinon/compare/v11.1.2...v12.0.0)

[Compare Source](https://togithub.com/sinonjs/sinon/compare/v11.1.2...v12.0.0)

</details>

---

### Configuration

📅 **Schedule**: "after 9am and before 3pm" (UTC).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR is behind base branch, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, click this checkbox.

---

This PR has been generated by [WhiteSource Renovate](https://renovate.whitesourcesoftware.com). View repository job log [here](https://app.renovatebot.com/dashboard#github/googleapis/nodejs-speech).
sofisl pushed a commit that referenced this issue Jan 25, 2023
[![WhiteSource Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
| [sinon](https://sinonjs.org/) ([source](https://togithub.com/sinonjs/sinon)) | [`^11.0.0` -> `^12.0.0`](https://renovatebot.com/diffs/npm/sinon/11.1.2/12.0.1) | [![age](https://badges.renovateapi.com/packages/npm/sinon/12.0.1/age-slim)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://badges.renovateapi.com/packages/npm/sinon/12.0.1/adoption-slim)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://badges.renovateapi.com/packages/npm/sinon/12.0.1/compatibility-slim/11.1.2)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://badges.renovateapi.com/packages/npm/sinon/12.0.1/confidence-slim/11.1.2)](https://docs.renovatebot.com/merge-confidence/) |

---

### Release Notes

<details>
<summary>sinonjs/sinon</summary>

### [`v12.0.1`](https://togithub.com/sinonjs/sinon/blob/master/CHANGES.md#&#8203;1201)

[Compare Source](https://togithub.com/sinonjs/sinon/compare/v12.0.0...v12.0.1)

-   [`3f598221`](https://togithub.com/sinonjs/sinon/commit/3f598221045904681f2b3b3ba1df617ed5e230e3)
    Fix issue with npm unlink for npm version > 6 (Carl-Erik Kopseng)
    > 'npm unlink' would implicitly unlink the current dir
    > until version 7, which requires an argument
-   [`51417a38`](https://togithub.com/sinonjs/sinon/commit/51417a38111eeeb7cd14338bfb762cc2df487e1b)
    Fix bundling of cjs module ([#&#8203;2412](https://togithub.com/sinonjs/sinon/issues/2412)) (Julian Grinblat)
    > -   Fix bundling of cjs module
    >
    > -   Run prettier

*Released by [Carl-Erik Kopseng](https://togithub.com/fatso83) on 2021-11-04.*

#### 12.0.0

### [`v12.0.0`](https://togithub.com/sinonjs/sinon/compare/v11.1.2...v12.0.0)

[Compare Source](https://togithub.com/sinonjs/sinon/compare/v11.1.2...v12.0.0)

</details>

---

### Configuration

📅 **Schedule**: "after 9am and before 3pm" (UTC).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR is behind base branch, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, click this checkbox.

---

This PR has been generated by [WhiteSource Renovate](https://renovate.whitesourcesoftware.com). View repository job log [here](https://app.renovatebot.com/dashboard#github/googleapis/nodejs-speech).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: storage Issues related to the Cloud Storage API. core type: question Request for information or clarification. Not an issue.
Projects
None yet
Development

No branches or pull requests

4 participants