-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Oauth2: Supported at the request level, but not at the collection level #1704
Comments
@jackj93 this isn't working for me either (v 1.12.1 now). Var isn't being set by the script either when hitting "Get Access Token" button on the Collection Authorization or in making a call that uses inherit authorization. |
@jackj93 did you have to install an external module for this to work?
Any idea? |
In the request themselves you have to set the "No Auth"
All the configuration I listed go in the configuration for the collection. do NOT put anything in the request settings |
Thank you @jackj93, it works now! Retrospectively I should've seen in the code that it was going in the post response part. |
Update: As of v1.11.0 I see that OAuth2 is supported at the collection level, but setting auth to 'inherit' at the request level isn't supported: Using @jackj93 's scripting provides a workaround: we can save the collection token as a variable and use that in requests in the appropriate place (for me, I set an |
In addition to the Post Request script by @jackj93, I'm using this Pre Request script on Collection level, then you don't need to add the header manually on each request:
|
Is there a way to reuse a token across multiple collections? I have many collections but they use the same OAuth provider. So now I have to get a token for each collection individually, instead of doing it once and reusing it in all collections. I guess a workaround would be to have only one collection per OAuth provider and group the requests in folders and subfolders. |
Workarounds aside (which work, thanks for that) is there intention to work on this formally? Debating the pros and cons of waiting on this to be solved upstream and permit inheritance on the collection requests when using Oauth2 instead of injecting a pre-script one every single request. Thanks |
After applying @jackj93's workaround (thanks for that) requests are fine, however, when attempting to get a new token I'm getting |
The work arounds suggested still seem to require manually clicking the "Get Access Token" on the collection every time the token expires. This isn't great for api's that use short lived tokens. Luckily the client credential flow can be automated fairly simply by adding the following Pre Request script on the collection:
This stores the access token and token expiration time in environment variables and checks each request to see if a new token needs to be retrieved. It would be really helpful if the bruno Oauth2 documentation for client credentials provided an example like this to simplify the authentication process. |
Since the majority of use-cases use the same scripts at this point, is there a reason why this functionality isn't baked into the client? |
When configuring OAuth 2.0, it would be helpful to configure once per collection instead of requiring configuration on individual requests:
Auth configuration at the request level:
Auth configuration at the collection level:
(This is for Bruno v1.10.0)
The text was updated successfully, but these errors were encountered: