Rails api is not returning access-token and client to external url via devise token auth










0















I'm having an issue with devise_token_auth returning a client and access-token back to my front end. It works fine in my test environment and I get the expected results. But in my dev environment I am using a external url. This is the response I get when I create a session:



 Object 
"config": Object
"adapter": [Function xhrAdapter],
"baseURL": "http://93ae6a5f.ngrok.io/api/v1",
"data": ""email":"test@gmail.com","password":"password"",
"headers": Object
"Accept": "application/json",
"Content-Type": "application/json",
,
"maxContentLength": -1,
"method": "post",
"timeout": 0,
"transformRequest": Object
"0": [Function transformRequest],
,
"transformResponse": Object
"0": [Function transformResponse],
,
"url": "http://93ae6a5f.ngrok.io/api/v1/auth/sign_in",
"validateStatus": [Function validateStatus],
"xsrfCookieName": "XSRF-TOKEN",
"xsrfHeaderName": "X-XSRF-TOKEN",
,
"data": Object
"data": Object
"allow_password_change": false,
"email": "test@gmail.com",
"id": 1,
"image": null,
"name": null,
"nickname": null,
"provider": "email",
"uid": "test@gmail.com",
"username": null,
,
,
"duration": 731,
"headers": Object
"cache-control": "public, max-age=0",
"content-type": "application/json; charset=utf-8",
"etag": "W/"0fa41fc630ddb8ffc9b9f9f9b90849b5"",
"transfer-encoding": "chunked",
"vary": "Origin",
"x-request-id": "320d3bd6-7e94-48b4-8e14-fe434d593b6a",
"x-runtime": "0.303548",
,
"ok": true,
"originalError": null,
"problem": null,
"status": 200,



I went through the devise_token_auth docs and have already added this to my application.rb



config.middleware.use Rack::Cors do
allow do
origins '*'
resource '*',
headers: :any,
expose: ['access-token', 'expiry', 'token-type', 'uid', 'client'],
methods: [:get, :post, :options, :delete, :put]
end
end


Anyone have any thoughts on how to get this working?










share|improve this question




























    0















    I'm having an issue with devise_token_auth returning a client and access-token back to my front end. It works fine in my test environment and I get the expected results. But in my dev environment I am using a external url. This is the response I get when I create a session:



     Object 
    "config": Object
    "adapter": [Function xhrAdapter],
    "baseURL": "http://93ae6a5f.ngrok.io/api/v1",
    "data": ""email":"test@gmail.com","password":"password"",
    "headers": Object
    "Accept": "application/json",
    "Content-Type": "application/json",
    ,
    "maxContentLength": -1,
    "method": "post",
    "timeout": 0,
    "transformRequest": Object
    "0": [Function transformRequest],
    ,
    "transformResponse": Object
    "0": [Function transformResponse],
    ,
    "url": "http://93ae6a5f.ngrok.io/api/v1/auth/sign_in",
    "validateStatus": [Function validateStatus],
    "xsrfCookieName": "XSRF-TOKEN",
    "xsrfHeaderName": "X-XSRF-TOKEN",
    ,
    "data": Object
    "data": Object
    "allow_password_change": false,
    "email": "test@gmail.com",
    "id": 1,
    "image": null,
    "name": null,
    "nickname": null,
    "provider": "email",
    "uid": "test@gmail.com",
    "username": null,
    ,
    ,
    "duration": 731,
    "headers": Object
    "cache-control": "public, max-age=0",
    "content-type": "application/json; charset=utf-8",
    "etag": "W/"0fa41fc630ddb8ffc9b9f9f9b90849b5"",
    "transfer-encoding": "chunked",
    "vary": "Origin",
    "x-request-id": "320d3bd6-7e94-48b4-8e14-fe434d593b6a",
    "x-runtime": "0.303548",
    ,
    "ok": true,
    "originalError": null,
    "problem": null,
    "status": 200,



    I went through the devise_token_auth docs and have already added this to my application.rb



    config.middleware.use Rack::Cors do
    allow do
    origins '*'
    resource '*',
    headers: :any,
    expose: ['access-token', 'expiry', 'token-type', 'uid', 'client'],
    methods: [:get, :post, :options, :delete, :put]
    end
    end


    Anyone have any thoughts on how to get this working?










    share|improve this question


























      0












      0








      0








      I'm having an issue with devise_token_auth returning a client and access-token back to my front end. It works fine in my test environment and I get the expected results. But in my dev environment I am using a external url. This is the response I get when I create a session:



       Object 
      "config": Object
      "adapter": [Function xhrAdapter],
      "baseURL": "http://93ae6a5f.ngrok.io/api/v1",
      "data": ""email":"test@gmail.com","password":"password"",
      "headers": Object
      "Accept": "application/json",
      "Content-Type": "application/json",
      ,
      "maxContentLength": -1,
      "method": "post",
      "timeout": 0,
      "transformRequest": Object
      "0": [Function transformRequest],
      ,
      "transformResponse": Object
      "0": [Function transformResponse],
      ,
      "url": "http://93ae6a5f.ngrok.io/api/v1/auth/sign_in",
      "validateStatus": [Function validateStatus],
      "xsrfCookieName": "XSRF-TOKEN",
      "xsrfHeaderName": "X-XSRF-TOKEN",
      ,
      "data": Object
      "data": Object
      "allow_password_change": false,
      "email": "test@gmail.com",
      "id": 1,
      "image": null,
      "name": null,
      "nickname": null,
      "provider": "email",
      "uid": "test@gmail.com",
      "username": null,
      ,
      ,
      "duration": 731,
      "headers": Object
      "cache-control": "public, max-age=0",
      "content-type": "application/json; charset=utf-8",
      "etag": "W/"0fa41fc630ddb8ffc9b9f9f9b90849b5"",
      "transfer-encoding": "chunked",
      "vary": "Origin",
      "x-request-id": "320d3bd6-7e94-48b4-8e14-fe434d593b6a",
      "x-runtime": "0.303548",
      ,
      "ok": true,
      "originalError": null,
      "problem": null,
      "status": 200,



      I went through the devise_token_auth docs and have already added this to my application.rb



      config.middleware.use Rack::Cors do
      allow do
      origins '*'
      resource '*',
      headers: :any,
      expose: ['access-token', 'expiry', 'token-type', 'uid', 'client'],
      methods: [:get, :post, :options, :delete, :put]
      end
      end


      Anyone have any thoughts on how to get this working?










      share|improve this question
















      I'm having an issue with devise_token_auth returning a client and access-token back to my front end. It works fine in my test environment and I get the expected results. But in my dev environment I am using a external url. This is the response I get when I create a session:



       Object 
      "config": Object
      "adapter": [Function xhrAdapter],
      "baseURL": "http://93ae6a5f.ngrok.io/api/v1",
      "data": ""email":"test@gmail.com","password":"password"",
      "headers": Object
      "Accept": "application/json",
      "Content-Type": "application/json",
      ,
      "maxContentLength": -1,
      "method": "post",
      "timeout": 0,
      "transformRequest": Object
      "0": [Function transformRequest],
      ,
      "transformResponse": Object
      "0": [Function transformResponse],
      ,
      "url": "http://93ae6a5f.ngrok.io/api/v1/auth/sign_in",
      "validateStatus": [Function validateStatus],
      "xsrfCookieName": "XSRF-TOKEN",
      "xsrfHeaderName": "X-XSRF-TOKEN",
      ,
      "data": Object
      "data": Object
      "allow_password_change": false,
      "email": "test@gmail.com",
      "id": 1,
      "image": null,
      "name": null,
      "nickname": null,
      "provider": "email",
      "uid": "test@gmail.com",
      "username": null,
      ,
      ,
      "duration": 731,
      "headers": Object
      "cache-control": "public, max-age=0",
      "content-type": "application/json; charset=utf-8",
      "etag": "W/"0fa41fc630ddb8ffc9b9f9f9b90849b5"",
      "transfer-encoding": "chunked",
      "vary": "Origin",
      "x-request-id": "320d3bd6-7e94-48b4-8e14-fe434d593b6a",
      "x-runtime": "0.303548",
      ,
      "ok": true,
      "originalError": null,
      "problem": null,
      "status": 200,



      I went through the devise_token_auth docs and have already added this to my application.rb



      config.middleware.use Rack::Cors do
      allow do
      origins '*'
      resource '*',
      headers: :any,
      expose: ['access-token', 'expiry', 'token-type', 'uid', 'client'],
      methods: [:get, :post, :options, :delete, :put]
      end
      end


      Anyone have any thoughts on how to get this working?







      ruby-on-rails devise ruby-on-rails-5 devise-token-auth






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 15 '18 at 20:53







      Jay

















      asked Nov 15 '18 at 20:17









      JayJay

      4631519




      4631519






















          1 Answer
          1






          active

          oldest

          votes


















          -1














          Did you add the following to your controller?



          include DeviseTokenAuth::Concerns::SetUserByToken 





          share|improve this answer























            Your Answer






            StackExchange.ifUsing("editor", function ()
            StackExchange.using("externalEditor", function ()
            StackExchange.using("snippets", function ()
            StackExchange.snippets.init();
            );
            );
            , "code-snippets");

            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "1"
            ;
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function()
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled)
            StackExchange.using("snippets", function()
            createEditor();
            );

            else
            createEditor();

            );

            function createEditor()
            StackExchange.prepareEditor(
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader:
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            ,
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );













            draft saved

            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53327285%2frails-api-is-not-returning-access-token-and-client-to-external-url-via-devise-to%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            -1














            Did you add the following to your controller?



            include DeviseTokenAuth::Concerns::SetUserByToken 





            share|improve this answer



























              -1














              Did you add the following to your controller?



              include DeviseTokenAuth::Concerns::SetUserByToken 





              share|improve this answer

























                -1












                -1








                -1







                Did you add the following to your controller?



                include DeviseTokenAuth::Concerns::SetUserByToken 





                share|improve this answer













                Did you add the following to your controller?



                include DeviseTokenAuth::Concerns::SetUserByToken 






                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Feb 9 at 12:27









                Ig NorandIg Norand

                233




                233





























                    draft saved

                    draft discarded
















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid


                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.

                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53327285%2frails-api-is-not-returning-access-token-and-client-to-external-url-via-devise-to%23new-answer', 'question_page');

                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    這個網誌中的熱門文章

                    Barbados

                    How to read a connectionString WITH PROVIDER in .NET Core?

                    Node.js Script on GitHub Pages or Amazon S3