Skip to content
This repository has been archived by the owner on Jul 15, 2023. It is now read-only.

ShowRequestsDialogAsync doesn't loads the friends on W8.1 #135

Open
CristiW opened this issue Mar 28, 2016 · 17 comments
Open

ShowRequestsDialogAsync doesn't loads the friends on W8.1 #135

CristiW opened this issue Mar 28, 2016 · 17 comments
Assignees
Labels

Comments

@CristiW
Copy link
Contributor

CristiW commented Mar 28, 2016

Hello,

I'm trying to invite friends to my app and the Webview used in FacebookDialog.xaml doesn't load all the content.
If I open the request url in a browser, example Microsoft Edge, the friends are correctly loaded.
To authenticate with FB I'm using SessionLoginBehavior::WebAuth to get a long live access token.
friendrequest

Update:
I did some script debugging and the client is receiving the content, but somehow the WebView doesn't process it. After a relative amount of time after the content is received, 30 seconds, 5 minutes, etc, the WebView will finally display the received friends.

@adiviness
Copy link
Contributor

SessionLoginBehavior::WebAuth does not currently support the feed/requests/send dialogs, it is something that we're actively looking into.

@adiviness adiviness added the bug label Mar 28, 2016
@adiviness
Copy link
Contributor

I think we now have a workaround for this problem. You will need to use the branch webauth_dialogs. This branch has code that will use a different version of the dialogs when login is performed via the SessionLoginBehavior::WebAuth flow. It does come with a couple caveats:

  1. The user will be asked to log into Facebook each time a dialog is created unless they check the "remember me" checkbox when they log in (it doesn't need to be the first login, but they will be asked each time until they do check it)
  2. There is additional configuration required for the dialogs to close properly and the results of the dialog to be passed back to the sdk.

Expounding on caveat 2, the WebAuth dialogs expect to be redirected to ms-app://<your app's SID here> in order to work properly. If you've set any OAuth redirect URIs in the app's configuration settings in the Facebook developer portal you will need to add an exemption for this ms-app URI otherwise Facebook will block it. Unfortunately, it currently does not seem that you can directly add the ms-app URI to the settings (You won't be able to save the change) so you will instead need to add a url that you control that will redirect to the ms-app URI.

Once you've added a new valid OAuth redirect URI to the app's settings, you need to specify this redirect url to the sdk. This can be done like:

FBSession^ sess = FBSession::ActiveSession;
sess->WebAuthDialogRedirectUrl = L"http://your_website.com/your_redirect_page/";

You can set this at the same time you're setting up the Windows app ID and the Facebook app ID.

In order for the correct data to come back from a call to show one of the dialogs (ex. FBSession::ShowFeedDialogAsync will return an object that contains the post ID on success) the url that you're redirecting to will need to append the query string of the request to the ms-app URI (so for the Feed dialog you would be redirecting to a url that looks like ms-app://<your app's SID here>?post_id=<some_number_from_facebook>). If you don't do this, then the dialog showing function will return an FBResult with an error message even if the action was successful.

Please let us know if this fixes the problem.

@CristiW
Copy link
Contributor Author

CristiW commented Apr 7, 2016

Hello,

I didn't tested properly the request functionality because I'm trying to create a redirect page.
However I did find an issue.
In the function DialogUrlBuilder::GetRedirectUriString, if the login is not made explicitly with WebAuth behavior, the redirect is not the one expected.
For example, I did an explicit login with WebAuth behavior and at the next app start, I used Silent behavior to reload the cached access token. In this case, the redirect is not the one webAuth.

Update:
I created a html page that redirects to ms-app://my app's SID here and I added it to Valid OAuth redirect URIs from Settings - Advanced page from Facebook Dashboard.
This link I added it to sess->WebAuthDialogRedirectUrl but I have an error when I call ShowRequestsDialogAsync.
Error message: Given URL is not allowed by the Application configuration: One or more of the given URLs is not allowed by the App's settings. It must match the Website URL or Canvas URL, or the domain must be a subdomain of one of the App's domains.

Regards,
Cristi

@adiviness
Copy link
Contributor

Yes, the new method of displaying the dialogs is only used when WebAuth is used as the login method. Silent is something that is going to require some more thought for how to integrate it properly. WebAuth will not show a dialog if there is a cached access token if you're just looking to avoid the dialog showing in that circumstance.

To fix that error message, you will need to do some additional configuration in the Facebook settings for the app. In settings => basic, you will need click "Add Platform" and select "Website". The you will need to set both the "App Domains" and the "Site URL" to the website name (ex. http://example.com).

@CristiW
Copy link
Contributor Author

CristiW commented Apr 8, 2016

Hello adiviness,

I will need more advice from you because the webAuth redirect part is not clear to me.
I created a html page that redirects to the following uri: ms-app://my app SID but I'm receiving an error message, as you said in previous post.
How do I append the query string to the ms-app URI? Do I need to modify the redirect URI for every request? Can you give me an example of how the URI should look, let's say for ShowFeedDialogAsync ?

Regards,
Cristi

@adiviness
Copy link
Contributor

Sure. So what's happening it sounds like is that the redirect to the ms-app URI is successful so the dialog closes and the sdk tries to take the query parameters from the response and use them to create an object that wraps up their values (for a feed dialog that object is FBFeedRequest). FBFeedRequest expects to find a key post_id in the response (see the Response Data section of https://developers.facebook.com/docs/sharing/reference/feed-dialog/v2.5). But because that key does not exist you'll get an FBError talking about a malformed response.

In order to fix this you need to take the query string from the request and append it to your response when you perform the redirect. So what you'll be redirecting to should look like ms-app://<SID here>?post_id=<some long number here>. How you actually append this data after the ms-app URI depends on the language you're using for the web server. Because the post_id will change for each post made with the feed dialog you will need to modify the redirect URI each time.

@adiviness
Copy link
Contributor

In the webauth_dialogs branch, theFBSession will now save the last successful login dialog flow, which should allow the SessionLoginBehavior::Silent login parameter to work correctly with the WebAuthenticationBroker based dialogs if it is used after SessionLoginBehavior::WebAuth.

@CristiW
Copy link
Contributor Author

CristiW commented Apr 11, 2016

Hello,

I used html with javascript to create the ms-app redirect url and I hope that the application SID is not sensitive information because it's hardcoded in the html.
Thank you for your help.

Regards,
Cristi

@alakshmi1030 alakshmi1030 self-assigned this Apr 25, 2016
@MarketMole
Copy link

Please excuse this intrusion. I do not know where else to post/look for this issue. I am no C++ coder, C# only, trying to get winsdkfb into a Universal project. Apparently FBUser.h is missing. Should it be? Should this file by dynamically created perhaps? I figured that the project should compile, and would except that this file is missing. Suggestions?

@adiviness
Copy link
Contributor

FBUser.h is a file that is generated during compile time. Are you using the nuget package or are you adding a direct reference to the repo? If you are not using the nuget package with a C# project you might see visual studio report some errors falsely because it hasn't finished building the repo yet.

@MarketMole
Copy link

Not using nuget, direct project inclusion in the solution.

\facebookwinsdk-master\winsdkfb\winsdkfb\winsdkfb.shared\facebooksession.h(21): fatal error C1083: Cannot open include file: 'FBUser.h': No such file or directory

I get to that and that's it.

@adiviness
Copy link
Contributor

Try building the project for x64 first and then back to whatever platform you're originally targeting.

If that still causes problems, make sure that you cloned the repo and didn't download the zip file instead. Then from a cmd prompt try running /winsdkfb/winsdkfb/winsdkfb.Shared/codegen.cmd.

@MarketMole
Copy link

I did download the zip, but will do a fetch from the repo now... will follow your instructions.

@MarketMole
Copy link

MarketMole commented May 16, 2016

Ah, there was a previous error that probably was choking the compile:
Could not find TextTransform, please add it to your PATH or have it available in C:\Program Files (x86)\Common Files\Microsoft Shared\TextTemplating\14.0 (VS2015) or C:\Program Files (x86)\Common Files\Microsoft Shared\TextTemplating\12.0 (VS2013)

Turns out I only have Microsoft.VisualStudio.TextTemplating.11.0 installed. Even though I'm running VS2013

I made a copy of 11.0 into 12.0, just to test, and I get a full compile now.

@adiviness
Copy link
Contributor

You will need to have TextTransform.exe in your path in order for codegen.cmd to run correctly, but that should be taken care of for you if you are compiling from within visual studio.

@MarketMole
Copy link

Thanks for your prompt attention to my comments. Sorry to have abducted this thread. I believe I can get the sample to run now.

@adiviness
Copy link
Contributor

No problem. In the future though, making a new github issue would be preferable :)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

4 participants