appointer / swaggervel

Swagger for Laravel
70 stars 40 forks source link

how to setup OAuth 2.0 with swaggervel? #14

Open thienth opened 6 years ago

thienth commented 6 years ago
Thank for your amazing lib. i'm setup appointer/swaggervel for my project and using laravel passport too. i need to pass throw passport to using api in swagger ui, then changed config/swaggervel.php like: `/* -------------------------------------------------------------------------- Uncomment to add response headers when swagger is generated
*/
'view-headers' => [
    'Access-Control-Allow-Origin' => '*',
    'Access-Control-Allow-Methods' => 'GET, POST',
    'Access-Control-Allow-Headers' => 'X-Requested-With',
],

/*
  |--------------------------------------------------------------------------
  | You can configure OAuth2 authorization by changing value to true
  |--------------------------------------------------------------------------
*/
'init-o-auth' => true,

/*
  |--------------------------------------------------------------------------
  | Default clientId. MUST be a string
  |--------------------------------------------------------------------------
*/
'client-id' => 'my client id',

/*
  |--------------------------------------------------------------------------
  | Default clientSecret. MUST be a string
  |--------------------------------------------------------------------------
*/
'client-secret' => 'my client secret',

/*
  |--------------------------------------------------------------------------
  | Realm query parameter (for oauth1) added to authorizationUrl and tokenUrl.
  | MUST be a string
  |--------------------------------------------------------------------------
*/
'realm' => '',

/*
  |--------------------------------------------------------------------------
  | Application name, displayed in authorization popup. MUST be a string
  |--------------------------------------------------------------------------
*/
'app-name' => 'my app name',

/*
  |--------------------------------------------------------------------------
  | Scope separator for passing scopes, encoded before calling, default value is a space
  | (encoded value %20). MUST be a string
  |--------------------------------------------------------------------------
*/
'scope-separator' => '',

/*
  |--------------------------------------------------------------------------
  | Additional query parameters added to authorizationUrl and tokenUrl.
  |--------------------------------------------------------------------------
*/
'additional-query-string-params' => [
    // 'QueryStringKey' => 'QueryStringValue'
],

/*
  |--------------------------------------------------------------------------
  | Only activated for the accessCode flow. During the authorization_code request to the tokenUrl,
  | pass the Client Password using the HTTP Basic Authentication scheme
  | (Authorization header with Basic base64encoded[client_id:client_secret]).
  |--------------------------------------------------------------------------
*/
'use-basic-auth-with-access-code-grant' => true,
`

but it isn't working. Can you check this, pls. Thank you.

fgreinus commented 6 years ago

Hey,

as I do not actively use the package myself I cannot say too much about how to make it work with oauth2. But there were a couple of questions and tickets around this in the past, maybe have a look at these:

9 #8 #7

Some of those were fixed in #10.

What's the error you are receiving? What exactly does not work? Could you please paste the config to pastebin.com (or another service like it)? Github markdown breaks some of the characters in your paste above.

yswtrue commented 6 years ago

You can check this issue https://github.com/DarkaOnLine/L5-Swagger/issues/57