Skip to content

[Java] Add authentication support (API key, HTTP basic) #826

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

Merged
merged 10 commits into from
Jun 5, 2015
Merged

[Java] Add authentication support (API key, HTTP basic) #826

merged 10 commits into from
Jun 5, 2015

Conversation

xhh
Copy link
Contributor

@xhh xhh commented Jun 5, 2015

Add HTTP basic and API key authentications to Java client, like what has been done for PHP and ruby clients (#765, #783), except that the authentications are stored in ApiClient instances rather than stored and accessible globally.

Some example code:

ApiClient client = new ApiClient();
client.setApiKey("special-key");

PetApi api = new PetApi(client);
api.getPetById(new Long(1));

For discussion, another global config approach might be (not implemented currently, pseudo code below):

Configuration.setApiKey("special-key");

then all ApiClient instances will use that key.

xhh added 10 commits May 21, 2015 22:05
Conflicts:
	modules/swagger-codegen/src/main/resources/Java/apiInvoker.mustache
	samples/client/petstore/java/src/main/java/io/swagger/client/ApiInvoker.java
Conflicts:
	modules/swagger-codegen/src/main/java/com/wordnik/swagger/codegen/languages/JavaClientCodegen.java
	modules/swagger-codegen/src/main/resources/Java/ApiClient.mustache
	modules/swagger-codegen/src/main/resources/Java/api.mustache
	samples/client/petstore/java/src/main/java/io/swagger/client/ApiClient.java
	samples/client/petstore/java/src/main/java/io/swagger/client/Configuration.java
	samples/client/petstore/java/src/main/java/io/swagger/client/api/PetApi.java
	samples/client/petstore/java/src/main/java/io/swagger/client/api/StoreApi.java
	samples/client/petstore/java/src/main/java/io/swagger/client/api/UserApi.java
	samples/client/petstore/java/src/test/java/io/swagger/client/ConfigurationTest.java
	samples/client/petstore/java/src/test/java/io/swagger/petstore/test/PetApiTest.java
fehguy added a commit that referenced this pull request Jun 5, 2015
[Java] Add authentication support (API key, HTTP basic)
@fehguy fehguy merged commit b4f153c into swagger-api:develop_2.0 Jun 5, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants