1

I am building a feature where the user can import his contacts form his hotmail, outlook, live emails.

I am using Live SDK javascript library to make it possible, I have to create a new app and set a redirect url. When user trigger an action the browser promt a window where the user log in an autorize the access to contact information.

I have the follow uri structure:

www.example.com/pools/12
www.example.com/pools/13
www.example.com/pools/{pool_id}

I set the redirect uri, to www.example.com, so when I trigger the event the browser prompt a window with the follow error:

The provided value for the input parameter 'redirect_uri' is not valid. The expected value is 'https://login.live.com/oauth20_desktop.srf' or a URL which matches the redirect URI registered for this client application.

but if i change the redirect uri from microsoft developer center to:

www.example.com/pools/12

and try again from this page the code works perfect.

I need set the redirect uri to accept all kind of uri, I also try to use a regex patter with out luck. This is the code that I use

<%= content_for :javascript do %>
  <script src="//js.live.net/v5.0/wl.js"></script>
  <script type="text/javascript">
    WL.init({
      client_id: '<%= ENV["LIVE_CLIENT"] %>',
      scope: ["wl.basic", "wl.contacts_emails"],
      response_type: "token"
    });

    $("#import-contacts-live").on("click", function(event) {
      event.preventDefault();
      WL.login({
        scope: ["wl.basic", "wl.contacts_emails"],
        redirect_uri: '<%= request.original_url %>',
      }).then(function (response){
        WL.api({
          path: "me/contacts",
          method: "GET"
        }).then(function (response) {
          console.log(response.data);
        },
        function (responseFailed) {
          console.log(responseFailed);
        });
      },
      function (responseFailed){
        console.log("Error signing in: " + responseFailed.error_description);
      });
    }); 
  </script>
<% end %>
kentverger
  • 475
  • 1
  • 5
  • 19

0 Answers0