The following forum(s) are migrating to a new home on Microsoft Q&A (Preview): Developing Universal Windows apps!

Ask new questions on Microsoft Q&A (Preview).
Interact with existing posts until December 13, 2019, after which content will be closed to all new and existing posts.

Learn More

 none
[UWP][C++] How to set redirect uri in WebTokenRequest? RRS feed

  • Question

  • Hi,

    I'm trying to use the WebAuthenticationCoreManager/WebTokenRequest which are new universal APIs from a UWP C++ blank app but I can only set the client id.  How do I set the redirect uri?

    The reason I need this is when I sign-in I get an error indicating that the edirect uri doesn't match, expected is the correct uri but passed is my client id! 

    I tried to set the redirect_uri property on the WebTokenRequest (in addition to authority & resource) but then get a "duplicate parameter" error.

    Interestingly the same also occurs from C# until I do the "Add connected Service" process, and then it suddenly works.  However I can't do the same for the C++ app as I just get an "INVALIDARG" error.

    Any ideas

    Thanks for all the help

    Thursday, September 10, 2015 4:07 PM

Answers

  • Had a bit more time so investigated further and found the answer.  

    In the end I installed fiddler so I can see the HTTPS traffic and through that I found that the redirect uri has a format of:

    ms-appx-web://Microsoft.AAD.BrokerPlugin/packageId

    package id can be found under the "App identity" section on the windows store dashboard.

    Adding this redirect uri to my azure AD worked!


    • Marked as answer by SpecWin Friday, October 30, 2015 9:34 AM
    Friday, October 30, 2015 9:34 AM

All replies

  • See https://github.com/Microsoft/Windows-universal-samples/blob/714722f53c3ae270f634f54cb2740411f6b11032/Samples/WebAuthenticationBroker/cpp/Scenario2_oAuthFacebook.xaml.cpp

    facebookURL += clientID + "&redirect_uri=" + Uri::EscapeComponent(FacebookCallbackUrl->Text) + "&scope=read_stream&display=popup&response_type=token";
    


    Best Regards,
    Please remember to mark the replies as answers if they help

    Friday, September 11, 2015 10:18 AM
  • Thanks IssueKiller,

    I'll take a look but I was hoping to use WebAuthenticationCoreManager instead of WebAuthenticationBroker.

    Any ideas how to do that?

    Thanks

    Friday, September 11, 2015 2:36 PM
  • Anyone help?
    Monday, September 14, 2015 9:06 AM
  • Anyone from MSFT comment? Looks like the API is heavily biased towards C#.
    Wednesday, September 16, 2015 6:19 PM
  • Hi,

    I'm trying to use the WebAuthenticationCoreManager & WebTokenRequest (which are new universal APIs) from a UWP C++ app but I can only set the client id.  How do I set the redirect uri?

    The reason I need this is when I sign-in I get an error indicating that the redirect uri doesn't match.  The error shows the expected uri (as set in Azure) but what appears to be passed is the client id! 

    I tried to set the redirect_uri property on the WebTokenRequest (in addition to authority & resource) but then get a "duplicate parameter" error.

    Interestingly the same also occurs from C# until I do the "Add connected Service" process, and then it suddenly works.  However I can't do the same for the C++ app it fails with "INVALIDARG" error.

    Any ideas

    Thanks for all the help

    Monday, September 21, 2015 11:04 AM
  • Have you seen this example? You don't have to worry about the Redirect URL, you cannot set it. The ID you're seeing in the error is probably the ms-appx://{sid} url, right? And yes, you need to add that to your Azure AD Application. 

    Also, you've posted in Developing Apps for Office 2013, which is not the right subforum.


    Please remember to mark your question as answered & Vote helpful
    Check my blog or follow me on Twitter


    Tuesday, September 22, 2015 1:14 AM
  • Yes it is mainly focusing on C#, but it should work the same on C++. Also see the answer in your other thread. You don't need to worry about the Redirect URL, you cannot configure it. However, you need to add it to your Azure AD Application.

    And I'm not sure why you want to use WebAuthenticationCoreManager, WebAuthenticationBroker is the way to go.


    Please remember to mark your question as answered & Vote helpful
    Check my blog or follow me on Twitter

    Tuesday, September 22, 2015 1:17 AM
  • Thanks Roland,

    I would like to use WebAuthenticationCoreManager as it is now recommended

    The WebAuthenticationBroker was a browser control on OAuth steroids. The Azure AD Authentication Libraries (ADAL) automatically leveraged this when you requested a token. The WebAuthenticationBroker worked great, but didn’t always look great within an app given it was loading a framed login screen. The WebAuthenticationBroker still exists in 2015, but the WebAccountProvider is a new mechanism to UWPs and provides a first class experience.

    See http://blogs.msdn.com/b/richard_dizeregas_blog/archive/2015/08/07/connecting-to-office-365-apis-from-a-windows-10-uwp.aspx

    I do have the redirect uri set in Azure but I get the mismatch error when calling this API from a C++ app. Doing the same through C# works when I use the Office 365 wizard (here I select the client id of the same app registered in Azure).  I've diffed the "before and after wizard" versions of the C# app but can't see anything to suggest why it works.

    Tuesday, September 22, 2015 8:19 AM
  • Had a bit more time so investigated further and found the answer.  

    In the end I installed fiddler so I can see the HTTPS traffic and through that I found that the redirect uri has a format of:

    ms-appx-web://Microsoft.AAD.BrokerPlugin/packageId

    package id can be found under the "App identity" section on the windows store dashboard.

    Adding this redirect uri to my azure AD worked!


    • Marked as answer by SpecWin Friday, October 30, 2015 9:34 AM
    Friday, October 30, 2015 9:34 AM