posty / posty_api

Utility to administrate mailserver based on postfix and dovecot
www.posty-soft.org
Other
85 stars 19 forks source link

{"error":"Unauthorized. Invalid or expired token."} #15

Closed metanerd closed 9 years ago

metanerd commented 9 years ago

Hi,

thanks for your work, I really appreciate the idea. A more detailed faq and documentation would be greatly appreciated though. I am a ruby noob. Anyway, I got a problem with the configuration of the communication with posty_api and posty_webui. When I open http://mydomain.com:9292/api/v1/domains I get {"error":"Unauthorized. Invalid or expired token."}

rspec runs with 22 finished examples and 0 failures,

I ran rake api_key:generate successfully, too. Access token shows up in the mysql db.

My posty_api/dev/settings.json:

{ "servers": [ { "caption": "posty server 1", "url": "mydomain.com/api/v1", "key": "51419874688388a2d566c55963a88995" // this is the token from the db. } ] }

Any help would be greatly appreciated.

Took me long hours... would not do it again. I am sure, it's me though.

tri-star commented 9 years ago

It seems that your client HTTP request header modified by web server or proxies.

If you use nginx, please refer "ignore_invalid_headers" settings. http://nginx.org/en/docs/http/ngx_http_core_module.html#ignore_invalid_headers

posty-api needs request header named "auth_token" to receive API key, however, nginx is remove those headers due to default setting of ignore_invalid_headers(=on) and underscores_in_headers(=off).

Gastonite commented 9 years ago

hi the posty-webui client is using Restangular for insert the access_token as a http header, whereas the posty-api is waiting for a query parameter

When i use Postman i'm able to request the api with api/v1/domains?auth_token={API Key} but not with a http header like Restangular.

chicobico commented 9 years ago

@metanerd is your problem fixed or does it still occurs?