Project

General

Profile

API REST - need another authentification for projects / users and not for issues or others

Added by Eric Perdigau over 5 years ago

Hi everybody

I'm sorry to ask something but i didn't find any response for this problem.

I'm trying to use API to connect redmine with datas from a software. This is just the beginning and i want to test the api and be confident with.
I trying use php and
  • i can connect with the api key,
  • i can get issues
  • i can create a project
  • but with projects or users authentification fails.

I tried /issues.json directly in the browser, it works
I tried /projects.json and there is a window asking me to connect. I'm entering log/pass form an administrator and it fails to connect.

Do you have any idea where i am wrong ? Is there any setting somewhere ?

Thanks a lot
Eric


Replies (5)

RE: API REST - need another authentification for projects / users and not for issues or others - Added by Mayama Takeshi over 5 years ago

I tried /issues.json directly in the browser, it works

I believe this is because by default, Redmine allows anonymous access to issues.

I don't know about php, but if you are going to use the REST API you can use curl to test the methods that you will need like this:

curl -v -H "Content-Type: application/json" -H "X-Redmine-API-Key: YOUR_API_KEY" http://YOUR_REDMINE_HOST/redmine/projects.json

RE: API REST - need another authentification for projects / users and not for issues or others - Added by Eric Perdigau over 5 years ago

Hi

thank a lot for your reponse.

I know the problem now : there is a plugin installed : favorite_projects.

This plugins is doing a redirection from projects to favorite_projects. That is the problem for sure.

But i don't have now the solution :
  • does anyone know how to ask the api with this plugin ?
  • other possiblity : i tried to uninstall the plugin but it ives me an error 500. What is the clean way to uninstall it do you know ?

Thanks a lot for your help

RE: API REST - need another authentification for projects / users and not for issues or others - Added by Mayama Takeshi over 5 years ago

does anyone know how to ask the api with this plugin ?

Take a look at the routes the plugin defines:

takeshi@takeshi:redmine_favorite_projects$ cat config/routes.rb 
#custom routes for this plugin

resources :favorite_project_queries

match "favorite_projects/favorite" => "favorite_projects#favorite", :via => [:post]
match "favorite_projects/unfavorite" => "favorite_projects#unfavorite", :via => [:delete]

match "favorite_projects/search" => "favorite_projects#search", :as => "search_favorite_projects", :via => [:get, :post]

match 'auto_completes/project_tags' => 'auto_completes#project_tags', :via => :get, :as => 'auto_complete_project_tags'

I have not tested but based on it:
A GET/POST to http://YOUR_REDMINE_HOST/redmine/favorite_projects/search permits to search for favorites.

i tried to uninstall the plugin but it ives me an error 500. What is the clean way to uninstall it do you know ?

The only plugins I ever installed didn't require DB changes (migrations). So I just had to remove the plugin folder and be done with it.
However, the plugin favorite_projects requires migrations:

takeshi@takeshi:redmine_favorite_projects$ ls db/migrate/
001_create_favorite_projects.rb  002_acts_as_taggable_migration.rb

So I would check how to rollback migration of rails projects.
I understand this is simple:
https://stackoverflow.com/questions/3647685/how-to-rollback-a-specific-migration

but you might want to backup your db before trying it.

RE: API REST - need another authentification for projects / users and not for issues or others - Added by Eric Perdigau over 5 years ago

Thanks for your answers
Uninstall is ok but after redmine is error 500 i don't understand why.

I managed to comment everything in init.rb for this plugin. It works, but it may not be the cleanest way to do ?

RE: API REST - need another authentification for projects / users and not for issues or others - Added by Mayama Takeshi over 5 years ago

To remove a plugin, usually we just remove its folder from inside the folder plugins.
So, you might have something like this:
redmine-3.4.2/plugins/redmine_favorite_projects
So just move redmine_favorite_projects to somewhere else (do not just delete the folder as you might need to unmigrate the DB if it turns out to be necessary and you will need to see what the migrations did when the plugin was installed).

    (1-5/5)