Getting 401 while calling the API in swagger but not through Postman

85 Views Asked by At

We've swagger implemented in our spring boot application using swagger-maven-plugin version 3.1.5 in pom.xml. The scheme is only https, basePath is just / and version is v1 While calling the api in Swagger, I'm getting 401 Unauthorized but it is working fine in postman. Also, I do not know how to bring up swagger in my local.

The plugin is configured like this

      <plugin>
                <groupId>com.github.kongchen</groupId>
                <artifactId>swagger-maven-plugin</artifactId>
                <version>3.1.5</version>
                <configuration>
                    <apiSources>
                      <apiSource>
                            <springmvc>true</springmvc>
                            <locations>com.services.myview.api</locations>
                            <schemes>https</schemes>
                            <basePath>/</basePath>
                            <info>
                                <title>My Web App</title>
                                <version>v1</version>
                                <description>My Web App</description>
                                <contact>
                                    <email>[email protected]</email>
                                    <name>Team-name</name>
                                    <url>a-confluence-url</url>
                                </contact>
                            </info>
                            <securityDefinitions>
                                   <securityDefinition>
                                          <name>oauth</name>
                                          <type>oauth</type>
                                   </securityDefinition>
                            </securityDefinitions>
                            <swaggerDirectory>${project.build.outputDirectory}</swaggerDirectory>
                     <attachSwaggerArtifact>true</attachSwaggerArtifact>
                        </apiSource>
                    </apiSources>
                </configuration>
                <executions>
                    <execution>
                        <phase>prepare-package</phase>
                        <goals>
                            <goal>generate</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
0

There are 0 best solutions below