question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to prefill API key for swagger UI

See original GitHub issue

I’m using:

  • Rails 4.2.6
  • Grape, Win Bouncer, Doorkeeper

How can I pre-fill API key for logged in user for swagger UI? The only way I figured out how to get the current token is by creating on separate rails app as an OauthClient. However, for convenience and in production I would like to prefill the api key in swagger UI. Or how can a logged in user get the api key easily?

wine_bouncer.rb:

WineBouncer.configure do |config|
  config.auth_strategy = :swagger

  config.define_resource_owner do
    User.find(doorkeeper_access_token.resource_owner_id) if doorkeeper_access_token
  end
end

swagger.rb:

GrapeSwaggerRails.options.url      = '/api/mobile/swagger_doc.json'
GrapeSwaggerRails.options.app_url  = 'https://www.domain.com'
GrapeSwaggerRails.options.api_key_name = 'access_token'
GrapeSwaggerRails.options.api_key_type = 'query'

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
nhinzecommented, Jul 22, 2016

I created a pull request to update the README.

0reactions
dblockcommented, Jul 22, 2016

Thanks @nhinze

Read more comments on GitHub >

github_iconTop Results From Across the Web

API Keys - Swagger
Some APIs use API keys for authorization. An API key is a token that a client provides when making API calls. The key...
Read more >
Adding Basic Authorization for Swagger-UI - Stack Overflow
In Swagger UI 3.13.0+, you can use the preauthorizeBasic method to pre-fill the Basic auth username and password for "try it out" calls....
Read more >
Web Component based Swagger & OpenAPI Spec ... - RapiDoc
Attributes ; api-key-value, Value of the API key that will be send while trying out the APIs. This can also be provided/overwritten from...
Read more >
Deposit Sign API v1 OAS3
Swagger UI. Select a definition. API V1 ... /swagger-api-doc/v1/swagger.json ... Get a pre-filled key application by CompanyCode and PersonalCode.
Read more >
App APIs - Airkit
Once the token has been created in the Console, go to Settings and add the API Key in API Key Filtering. This will...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found