lynndylanhurley / lynndylanhurley/devise_token_auth

validate_token route omits specified json format

Open
#1,031 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Ruby
Stars
3.6k
Forks
1.1k
PR merge metrics
No merged PRs in 30d

Description

At each request /api/v1/auth/validate_token browser gets response in JSON format, but it is logged like HTML.

rails server log:

> Started GET "/api/v1/auth/validate_token" for 127.0.0.1 at 2017-11
> Processing by DeviseTokenAuth::TokenValidationsController#validate_token **as HTML**

In browser response is returned like JSON

Request headers:
> Accept: application/json, text/plain, */*

Response headers:
> Content-Type: application/json; charset=utf-8

routes.rb
```
scope '/api/v1', defaults: {format: :json} do
mount_devise_token_auth_for 'User', at: 'auth'
#
end
```
rake routes
```
user_confirmation POST /api/v1/auth/confirmation(.:format) devise_token_auth/confirmations#create {:format=>:json}
new_user_confirmation GET /api/v1/auth/confirmation/new(.:format) devise_token_auth/confirmations#new {:format=>:json}
GET /api/v1/auth/confirmation(.:format) devise_token_auth/confirmations#show {:format=>:json}
api_v1_auth_validate_token GET /api/v1/auth/validate_token(.:format) devise_token_auth/token_validations#validate_token
GET /api/v1/auth/validate_token(.:format) devise_token_auth/token_validations#validate_token
GET /api/v1/auth/validate_token(.:format) devise_token_auth/token_validations#validate_token
GET /api/v1/auth/validate_token(.:format) devise_token_auth/token_validations#validate_token
api_v1_auth_failure GET /api/v1/auth/failure(.:format) devise_token_auth/omniauth_callbacks#omniauth_failure
GET /api/v1/auth/:provider/callback(.:format) devise_token_auth/omniauth_callbacks#omniauth_success
GET|POST /omniauth/:provider/callback(.:format) devise_token_auth/omniauth_callbacks#redirect_callbacks
omniauth_failure GET|POST /omniauth/failure(.:format) devise_token_auth/omniauth_callbacks#omniauth_failure
```

I also noticed some strange path helpers name **api_v1_auth_validate_token** and **api_v1_auth_failure**. It could be unnoticed when routes were written with [namespace](http://api.rubyonrails.org/classes/ActionDispatch/Routing/Mapper/Scoping.html#method-i-namespace).

I don't use omniauth. May further paths be duplicates for GET method?
```
api_v1_auth_failure GET /api/v1/auth/failure(.:format) devise_token_auth/omniauth_callbacks#omniauth_failure
GET /api/v1/auth/:provider/callback(.:format) devise_token_auth/omniauth_callbacks#omniauth_success
GET|POST /omniauth/:provider/callback(.:format) devise_token_auth/omniauth_callbacks#redirect_callbacks
omniauth_failure GET|POST /omniauth/failure(.:format) devise_token_auth/omniauth_callbacks#omniauth_failure
```

Or did I make something wrong?

Contributor guide

Open the contributing guide

Research direction

Start with the routes.rb scope and compare its declared defaults with the validate_token and omniauth entries shown by rake routes. Trace how those routes reach DeviseTokenAuth::TokenValidationsController#validate_token, then verify that the route uses the JSON format and that any duplicate GET routes are accounted for in the generated route list.

Written by the indexing model from the issue text.

Assessment

Tech stack
rails, ruby
Domain
api, authentication, backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.