deviseでの`downcase' for nil:NilClassエラー


## 背景
Rails6でdeviseでサインアップAPI作成中に遭遇
取り急ぎ解決したのでメモ書き程度に記載。


## エラー内容


```
$ curl -X POST http://localhost:3015/api/v1/auth -d '[name]=test2&[email]=test2@example.com&[password]=password&[password_confirmation]=password'
{"status":500,"error":"Internal Server Error","exception":"#\u003cNoMethodError: undefined method `downcase' for nil:NilClass\u003e","traces":{"Application Trace":[],"Framework Trace":[{"exception_object_id":15280,"id":0,"trace":"rack (2.2.4) lib/rack/utils.rb:464:in `[]='"},{"exception_object_id":15280,"id":1,"trace":"rack (2.2.4) lib/rack/utils.rb:432:in `block in initialize'"},{"exception_object_id":15280,"id":2,"trace":"rack (2.2.4) lib/rack/utils.rb:432:in `each'"},{"exception_object_id":15280,"id":3,"trace":"rack (2.2.4) lib/rack/utils.rb:432:in `initialize'"},{"exception_object_id":15280,"id":4,"trace":"rack (2.2.4) lib/rack/utils.rb:425:in `new'"},{"exception_object_id":15280,"id":5,"trace":"rack (2.2.4) lib/rack/utils.rb:425:in `[]'"},{"exception_object_id":15280,"id":6,"trace":"rack (2.2.4) lib/rack/etag.rb:29:in `call'"},{"exception_object_id":15280,"id":7,"trace":"rack (2.2.4) lib/rack/conditional_get.rb:40:in `call'"},{"exception_object_id":15280,"id":8,"trace":"rack (2.2.4) lib/rack/head.rb:12:in `call'"},{"exception_object_id":15280,"id":9,"trace":"activerecord (6.1.7) lib/active_record/migration.rb:601:in `call'"},{"exception_object_id":15280,"id":10,"trace":"actionpack (6.1.7) lib/action_dispatch/middleware/callbacks.rb:27:in `block in call'"},{"exception_object_id":15280,"id":11,"trace":"activesupport (6.1.7) lib/active_support/callbacks.rb:98:in `run_callbacks'"},{"exception_object_id":15280,"id":12,"trace":"actionpack (6.1.7) lib/action_dispatch/middleware/callbacks.rb:26:in `call'"},{"exception_object_id":15280,"id":13,"trace":"actionpack (6.1.7) lib/action_dispatch/middleware/executor.rb:14:in `call'"},{"exception_object_id":15280,"id":14,"trace":"actionpack (6.1.7) lib/action_dispatch/middleware/actionable_exceptions.rb:18:in `call'"},{"exception_object_id":15280,"id":15,"trace":"actionpack (6.1.7) lib/action_dispatch/middleware/debug_exceptions.rb:29:in `call'"},{"exception_object_id":15280,"id":16,"trace":"actionpack (6.1.7) lib/action_dispatch/middleware/show_exceptions.rb:33:in `call'"},{"exception_object_id":15280,"id":17,"trace":"railties (6.1.7) lib/rails/rack/logger.rb:37:in `call_app'"},{"exception_object_id":15280,"id":18,"trace":"railties (6.1.7) lib/rails/rack/logger.rb:26:in `block in call'"},{"exception_object_id":15280,"id":19,"trace":"activesupport (6.1.7) lib/active_support/tagged_logging.rb:99:in `block in tagged'"},{"exception_object_id":15280,"id":20,"trace":"activesupport (6.1.7) lib/active_support/tagged_logging.rb:37:in `tagged'"},{"exception_object_id":15280,"id":21,"trace":"activesupport (6.1.7) lib/active_support/tagged_logging.rb:99:in `tagged'"},{"exception_object_id":15280,"id":22,"trace":"railties (6.1.7) lib/rails/rack/logger.rb:26:in `call'"},{"exception_object_id":15280,"id":23,"trace":"actionpack (6.1.7) lib/action_dispatch/middleware/remote_ip.rb:81:in `call'"},{"exception_object_id":15280,"id":24,"trace":"actionpack (6.1.7) lib/action_dispatch/middleware/request_id.rb:26:in `call'"},{"exception_object_id":15280,"id":25,"trace":"rack (2.2.4) lib/rack/runtime.rb:22:in `call'"},{"exception_object_id":15280,"id":26,"trace":"activesupport (6.1.7) lib/active_support/cache/strategy/local_cache_middleware.rb:29:in `call'"},{"exception_object_id":15280,"id":27,"trace":"actionpack (6.1.7) lib/action_dispatch/middleware/executor.rb:14:in `call'"},{"exception_object_id":15280,"id":28,"trace":"actionpack (6.1.7) lib/action_dispatch/middleware/static.rb:24:in `call'"},{"exception_object_id":15280,"id":29,"trace":"rack (2.2.4) lib/rack/sendfile.rb:110:in `call'"},{"exception_object_id":15280,"id":30,"trace":"actionpack (6.1.7) lib/action_dispatch/middleware/host_authorization.rb:148:in `call'"},{"exception_object_id":15280,"id":31,"trace":"rack-cors (1.1.1) lib/rack/cors.rb:100:in `call'"},{"exception_object_id":15280,"id":32,"trace":"railties (6.1.7) lib/rails/engine.rb:539:in `call'"},{"exception_object_id":15280,"id":33,"trace":"puma (5.6.5) lib/puma/configuration.rb:252:in `call'"},{"exception_object_id":15280,"id":34,"trace":"puma (5.6.5) lib/puma/request.rb:77:in `block in handle_request'"},{"exception_object_id":15280,"id":35,"trace":"puma (5.6.5) lib/puma/thread_pool.rb:340:in `with_force_shutdown'"},{"exception_object_id":15280,"id":36,"trace":"puma (5.6.5) lib/puma/request.rb:76:in `handle_request'"},{"exception_object_id":15280,"id":37,"trace":"puma (5.6.5) lib/puma/server.rb:443:in `process_client'"},{"exception_object_id":15280,"id":38,"trace":"puma (5.6.5) lib/puma/thread_pool.rb:147:in `block in spawn_thread'"}],"Full Trace":[{"exception_object_id":15280,"id":0,"trace":"rack (2.2.4) lib/rack/utils.rb:464:in `[]='"},{"exception_object_id":15280,"id":1,"trace":"rack (2.2.4) lib/rack/utils.rb:432:in `block in initialize'"},{"exception_object_id":15280,"id":2,"trace":"rack (2.2.4) lib/rack/utils.rb:432:in `each'"},{"exception_object_id":15280,"id":3,"trace":"rack (2.2.4) lib/rack/utils.rb:432:in `initialize'"},{"exception_object_id":15280,"id":4,"trace":"rack (2.2.4) lib/rack/utils.rb:425:in `new'"},{"exception_object_id":15280,"id":5,"trace":"rack (2.2.4) lib/rack/utils.rb:425:in `[]'"},{"exception_object_id":15280,"id":6,"trace":"rack (2.2.4) lib/rack/etag.rb:29:in `call'"},{"exception_object_id":15280,"id":7,"trace":"rack (2.2.4) lib/rack/conditional_get.rb:40:in `call'"},{"exception_object_id":15280,"id":8,"trace":"rack (2.2.4) lib/rack/head.rb:12:in `call'"},{"exception_object_id":15280,"id":9,"trace":"activerecord (6.1.7) lib/active_record/migration.rb:601:in `call'"},{"exception_object_id":15280,"id":10,"trace":"actionpack (6.1.7) lib/action_dispatch/middleware/callbacks.rb:27:in `block in call'"},{"exception_object_id":15280,"id":11,"trace":"activesupport (6.1.7) lib/active_support/callbacks.rb:98:in `run_callbacks'"},{"exception_object_id":15280,"id":12,"trace":"actionpack (6.1.7) lib/action_dispatch/middleware/callbacks.rb:26:in `call'"},{"exception_object_id":15280,"id":13,"trace":"actionpack (6.1.7) lib/action_dispatch/middleware/executor.rb:14:in `call'"},{"exception_object_id":15280,"id":14,"trace":"actionpack (6.1.7) lib/action_dispatch/middleware/actionable_exceptions.rb:18:in `call'"},{"exception_object_id":15280,"id":15,"trace":"actionpack (6.1.7) lib/action_dispatch/middleware/debug_exceptions.rb:29:in `call'"},{"exception_object_id":15280,"id":16,"trace":"actionpack (6.1.7) lib/action_dispatch/middleware/show_exceptions.rb:33:in `call'"},{"exception_object_id":15280,"id":17,"trace":"railties (6.1.7) lib/rails/rack/logger.rb:37:in `call_app'"},{"exception_object_id":15280,"id":18,"trace":"railties (6.1.7) lib/rails/rack/logger.rb:26:in `block in call'"},{"exception_object_id":15280,"id":19,"trace":"activesupport (6.1.7) lib/active_support/tagged_logging.rb:99:in `block in tagged'"},{"exception_object_id":15280,"id":20,"trace":"activesupport (6.1.7) lib/active_support/tagged_logging.rb:37:in `tagged'"},{"exception_object_id":15280,"id":21,"trace":"activesupport (6.1.7) lib/active_support/tagged_logging.rb:99:in `tagged'"},{"exception_object_id":15280,"id":22,"trace":"railties (6.1.7) lib/rails/rack/logger.rb:26:in `call'"},{"exception_object_id":15280,"id":23,"trace":"actionpack (6.1.7) lib/action_dispatch/middleware/remote_ip.rb:81:in `call'"},{"exception_object_id":15280,"id":24,"trace":"actionpack (6.1.7) lib/action_dispatch/middleware/request_id.rb:26:in `call'"},{"exception_object_id":15280,"id":25,"trace":"rack (2.2.4) lib/rack/runtime.rb:22:in `call'"},{"exception_object_id":15280,"id":26,"trace":"activesupport (6.1.7) lib/active_support/cache/strategy/local_cache_middleware.rb:29:in `call'"},{"exception_object_id":15280,"id":27,"trace":"actionpack (6.1.7) lib/action_dispatch/middleware/executor.rb:14:in `call'"},{"exception_object_id":15280,"id":28,"trace":"actionpack (6.1.7) lib/action_dispatch/middleware/static.rb:24:in `call'"},{"exception_object_id":15280,"id":29,"trace":"rack (2.2.4) lib/rack/sendfile.rb:110:in `call'"},{"exception_object_id":15280,"id":30,"trace":"actionpack (6.1.7) lib/action_dispatch/middleware/host_authorization.rb:148:in `call'"},{"exception_object_id":15280,"id":31,"trace":"rack-cors (1.1.1) lib/rack/cors.rb:100:in `call'"},{"exception_object_id":15280,"id":32,"trace":"railties (6.1.7) lib/rails/engine.rb:539:in `call'"},{"exception_object_id":15280,"id":33,"trace":"puma (5.6.5) lib/puma/configuration.rb:252:in `call'"},{"exception_object_id":15280,"id":34,"trace":"puma (5.6.5) lib/puma/request.rb:77:in `block in handle_request'"},{"exception_object_id":15280,"id":35,"trace":"puma (5.6.5) lib/puma/thread_pool.rb:340:in `with_force_shutdown'"},{"exception_object_id":15280,"id":36,"trace":"puma (5.6.5) lib/puma/request.rb:76:in `handle_request'"},{"exception_object_id":15280,"id":37,"trace":"puma (5.6.5) lib/puma/server.rb:443:in `process_client'"},{"exception_object_id":15280,"id":38,"trace":"puma (5.6.5) lib/puma/thread_pool.rb:147:in `block in spawn_thread'"}]}}%  
```

## 試したこと

https://github.com/lynndylanhurley/devise_token_auth/issues/1540
authorizationを加えれば解決するとのことで試してみる


```diff_ruby
  config.headers_names = {:'access-token' => 'access-token',
                         :'client' => 'client',
                         :'expiry' => 'expiry',
                         :'uid' => 'uid',
                         :'token-type' => 'token-type',
+                        :'authorization' => "authorization" }
```

## 結果


成功。
authorizationの問題？

```
$ curl -X POST http://localhost:3015/api/v1/auth -d '[name]=test3&[email]=test3@example.com&[password]=password&[password_confirmation]=password'
{"status":"success","data":{"email":"test3@example.com","provider":"email","uid":"test3@example.com","id":3,"allow_password_change":false,"name":"test3","nickname":null,"image":null,"created_at":"2022-10-23T07:49:40.510Z","updated_at":"2022-10-23T07:49:40.677Z"}}%    
```