Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • O openapi-generator
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 3,476
    • Issues 3,476
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 402
    • Merge requests 402
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • OpenAPI Tools
  • openapi-generator
  • Issues
  • #2561
Closed
Open
Issue created Apr 01, 2019 by Administrator@rootContributor4 of 6 checklist items completed4/6 checklist items

[BUG][Java][feign] NPE on OAuth2 when 'expires_in' data is not provided by authentication server

Created by: thibaudsowa

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator (example)?
  • What's the version of OpenAPI Generator used?
  • Have you search for related issues/PRs?
  • What's the actual output vs expected output?
  • [Optional] Bounty to sponsor the fix (example)
Description

If OAuth server doesn't provide time of token expiration with the attribute expires_in a NPE append. For my example: Salesforce API.

openapi-generator version

Swagger Codegen 2.2.3

OpenAPI declaration file content or url
---
swagger: '2.0'
info:
  version: v1
  title: Test oauth
paths:
  "/test":
    post:
      consumes:
      - application/json
      produces:
      - application/json
      responses:
        '201':
          description: Success
securityDefinitions:
  OAuth:
    type: oauth2
    flow: password
    tokenUrl: https://test.salesforce.com/services/oauth2/token
security:
- OAuth: []
Command line used for generation
java -jar swagger-codegen-cli.jar generate \
   -i swagger.yaml \
   -l java \
   -o ./generated \
   --library feign
Steps to reproduce

Just try to request an authenticated resource with OAuth2 on an authentication server that does not provide expires_in data:

ApiClient apiClient = new ApiClient("OAuth", "clientId", "secret", "username", "password");
apiClient.setBasePath("https://test.my.salesforce.com");

DefaultApi defaultApi = apiClient.buildClient(DefaultApi.class);
defaultApi.testPost();
Suggest a fix

If expires_in is not provided by authentication server we can not know the time of expiration, so the authentication token should be asked on every request? Or at least provide a default timeout that can be customized?

Assignee
Assign to
Time tracking