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
Change unauthorized error 401 with Rest API #20
Comments
You can check the login method on class com.openkm.rest.endpoint.AuthService to debug and customize the response for login API. |
Dear Vohoailen thanks so much for your reply |
Rest goes with "basic" authentication and error 401 is right you will not be able to change it from source code, because really your call not arrive to the method code. Login method really it is not for login, this method must be used when users had never logged from the UI. I will try to explain, when you login from UI - first time - are done some special task by the repository ( create user trash, etc... ). Unfortunately when you are accessing exclusively from API these task are not done, and that's the reason why we created login method ( in this scenario should be executed at least one time ). Might be login method name cause some confusion, because this is not really for login, is for something what happens first time you have been logged. |
Thanks Dear Darkman97i for your reply
|
Should be changed the basic authentication for other, for example based in token or try to get both working together. What is the problem for you with basic authentication ( browser asking for user and password ? ) ? |
|
Is not a problem with basic authentication, you are doing bad javascript call. Take a look at this javascript project what connects to OpenKM with javascript https://github.com/darkman97i/kamify/blob/master/js/download.js |
Dear Darkman thanks so much I do not know how can I appreciate your help because OKM using basic authentication I will try to get user name and password from user then make AJAX call to ( openKM/services/rest/login ) if i get HTTP status OK like (204) then I will store this user name and password from client side to future Request , then i will drive user to another page to make further request , i made call ( openKM/services/rest ) just for test if this user name and password is right but unfortunately it made this big problem for me . |
I do not know why are you using javascript, why do not try to integrate SDK for JAVA, https://docs.openkm.com/kcenter/view/sdk4j-1.1/ with your own authentication provider ? |
Dear Mr. Darkman thanks a lot to your reply yes it is interested why I do not using SDK I will go along with SDK , but this will not make any problem for me like some thing can be done with RESR API can not be done with SDK ? |
OpenKM SDK is a wrapper client for REST webservices. All API REST methods are available from SDK ( if you find some method available from REST not exposed across SDK might be bug ). |
Try again please, because today we have been moving the maven to another server and might have been some issues with it ( the dns change might need 24 hours to be propagated, if in 24 hours the error persist tell us ). |
Dear Darkman from previous comment you said
|
Last question, it does not have any relation with the issue I will proceed closing it. If you want to discuss about new feature etc... , please do from our public forum at https://forum.openkm.com/viewforum.php?f=31 ( Auth API is not all exposed with webservices, if you want to collaborate on extending it, tell us and we'll try to give you the clues for it ). This is the actual existing class for it, what should be extended https://github.com/openkm/document-management-system/blob/6.3-DEV/src/main/java/com/openkm/ws/endpoint/AuthService.java ( us we can suggest you how doing it ). |
Hi guys your help please
I tried to connect to openKM via Rest API but i have problem when i send request to check login credential and username i get error 401 back and this error is handing by browser and some boring window will appear i want change this error from source code to send back another error number instate of error 401 to prevent browser to show this window , could you please help me how can I do that inside source code ?
The text was updated successfully, but these errors were encountered: