Skip to content

Commit

Permalink
Pass api key and username in the header
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinDelille committed Sep 26, 2020
1 parent b0890bd commit 7794e90
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
package org.xwiki.contrib.usersync.discourse.internal;

import retrofit2.Call;
import retrofit2.http.*;

import org.xwiki.contrib.usersync.discourse.internal.*;
import retrofit2.http.Body;
import retrofit2.http.DELETE;
import retrofit2.http.GET;
import retrofit2.http.POST;
import retrofit2.http.Path;
import retrofit2.http.Header;

public interface DiscourseService {
@GET("users/{username}.json")
Call<GetUserResponse> getUser(@Path("username") String username, @Query("api_key") String apiKey, @Query("api_username") String apiUsername);
Call<GetUserResponse> getUser(@Path("username") String username, @Header("Api-Key") String apiKey, @Header("Api-Username") String apiUsername);

@POST("users")
Call<CreateUserResponse> createUser(@Body CreateUserBody createUserBody, @Query("api_key") String apiKey, @Query("api_username") String apiUsername);
Call<CreateUserResponse> createUser(@Body CreateUserBody createUserBody, @Header("Api-Key") String apiKey, @Header("Api-Username") String apiUsername);

@DELETE("/admin/users/{userid}.json")
Call<DeleteUserResponse> deleteUser(@Path("userid") Integer userId, @Query("api_key") String apiKey, @Query("api_username") String apiUsername);
Call<DeleteUserResponse> deleteUser(@Path("userid") Integer userId, @Header("Api-Key") String apiKey, @Header("Api-Username") String apiUsername);
}

Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ public void createUser(BaseObject userObject) throws UserSyncException {
}
} catch (IOException exception) {
System.out.println(exception.getMessage());
throw new UserSyncException("Unknown error:" + exception.getMessage());

This comment has been minimized.

Copy link
@tmortagne

tmortagne Sep 26, 2020

Member

You should pass the other exception as second parameter instead of just the message.

}
}

Expand Down

0 comments on commit 7794e90

Please sign in to comment.