Specify request parameters in dotnetopenauth 4 - facebook

I need to get Facebook display a "Log in to Facebook" prompt rather than a "Go to App" action when performing OAuth. In order to do this, I need to specify "display=popup" as part of the request.
How can I do this when performing OAuth with DotNetOpenAuth 4 using their WebServerClient object?
It seems in previous versions there was a requestParameters parameter in PrepareRequestUserAuthorization but now it just takes an IEnumerable listing scopes.
Thanks

Add the display=popup query parameter to the URL you set on AuthorizationServerDescription.AuthorizationEndpoint.

Related

How to chain requests using Insomnia (get token from login api to use as header for other api)

I'm trying to update the header for my apis with a sif token that is retrieved from another login call. I know how to do this in Postman. There I go to the Tests tab and add something like this for the login api, which would set my global variable.
var data = JSON.parse(responseBody);
postman.setGlobalVariable("SIF_TEACHER", data.sifToken);
I've read this tutorial from the Insomnia official support page but can't really understand it and couldn't find any other doc on chaining requests there.
Thank you.
In your workspace press CTRL+E to open "Manage Environments" window
Add a variable like "token" to the environment
Put a response function (teal f) as value of this variable by pressing CTRL+SPACE.
Select one to your liking from the dropdown, in your case "Response => Body Attribute" should work well.
This will open a "Tag" form, like this one:
Select your login request and filter the response json or xml for the value containing your token value, f.e. $.access_token. Probably set trigger behaviour to "When Expired" too.
You can now access this variable anywhere in your workspace for other requests by pressing CTRL+SPACE in any form field and selecting the variable (purple x).
If you only need this for one request, you can skip setting up the environment variable for this and directly put the function where you need it, same way as described before.
You can check the link, in the comments there is a mini clip with the indications
https://github.com/Kong/insomnia/issues/2744
There is a plugin that allows you to have variables which you can set its value from different request an use them in others. This is great for when you want to chain requests but you have multiple possible parents and don't want to duplicate the child request, for example you could have "Login with A" and "Login with B" and both save to id, then you can have a "Get info" with the id.
Setting a variable is done using an special tag in the header of the request ("Save variable") and then use its value wherever you want with the "Variable" tag.
You can see more about the plugin in https://insomnia.rest/plugins/insomnia-plugin-save-variables .

Facebook authentication within a Page Tab

According to the specification here: http://developers.facebook.com/docs/authentication/pagetab/ I want to autorize user with the server-side flow on page tab. I use PHP-SDK.
My redirect_uri parameter is build like that:
https://www.facebook.com/pages/null/PAGE_ID/app_YOUR_APP_ID
and I keep getting:
API Error Code: 191
API Error Description: The specified URL is not owned by the application
I was trying many different settings combinations. Now I have filled fields: App Domains,Site URL,Canvas URL,Secure Canvas URL,Page Tab URL,Secure Page Tab URL but still without success. Addresses are ending with / and are all the same.
Link are build proper by the sdk. I test building it "by hand" without encoding of redirect_uri param and redirect link build like that:
https://www.facebook.com/PAGE_USERNAME/app_YOUR_APP_ID
https://www.facebook.com/pages/Page_Title/PAGE_ID?sk=app_YOUR_APP_ID
Can someone tell me what i'm doing wrong?
The answer to that question is that facebook documentation is incorrect. Format of return_uri that worked is:
https://www.facebook.com/pages/null/PAGE_ID?sk=app_YOUR_APP_ID
The format of return_uri changed again, the new format is:
https://www.facebook.com/PAGE_NAME?sk=app_YOUR_APP_ID

facebook oauth authentication doesn't return "code" parameter

I'm trying to use facebook's oauth.
Basically facebook has to return me a "code" parameter.
But i get nothing, it just return my callback url (to the exact same url).
i'm generating this url with my app.
http://www.facebook.com/dialog/oauth?client_id=76209388873&redirect_uri=http%3A%2F%2Ffb.lous%2Fmain%2Ffacebook_callback&scope=read_stream
I used other parameters and options, just when i set response_type=token
i get parameter list for javascript (with # character instead of ?, its for client side, i'm trying to write some api bot)
So right now i can't get any parameter with someway.
I tried to solve exactly the same thing for several hours. In my case it turned out to be a stupid redirect problem. Facebook correctly redirected back to http://www.mysite.com with the code parameter, then my webapp redirected to http://www.mysite.com/users/login (because the user wasn't logged in yet). On the second redirect I lost the code parameter.

on facebook connect login uri, can I add an extra get param on url, and have that passed to my script once user logs in?

to connect to an app on facebook, the user types in
www.facebook.com/login.php?api=12312312323123123
how can I add an extra get var to this url and pass it to my script on successful login?
Do you add a redirect_url as part of the login call?
If so you can add the GET parameter to that. For instance let us say you are asking Facebook to redirect to http://tld/fbhandler after user logs in. You can change that to http://tld/fbhandler?extra=value.
This URL is specified at the time of making the (OAuth) login call to Facebook and therefore you can change the value as you see fit.
You cannot do this. Facebook will strip custom query values from the url. I have found that there are two ways to do this. The first is that they will let you have a single query value at the end of the url if you encode the ? to %3F. For example:
redirect_url=http://www.example.com%3FmyextraParameter
You could use this approach to do something like base64url encode your values and add them at the end.
The other thing that I have done is to change the parameters to be path variables
redirect_url=http://www.example.com/realUrl/parameter1/parameter2
Neither are great solutions, but I have yet to find a way to send querystring values without them being stripped off.

Facebook status update URL

Does Facebook provide a URL the user can access that will take him to his profile page with the "What's on your mind" box auto completed with a value provided in the URL? I need something like "http://facebook.com?status=This is my new status message".
Use FB.Connect.streamPublish, like so:
FB.Connect.streamPublish("I just visited dandu's website!");
Of course, this means creating an application and loading the Facebook Connect JS libraries in your website, check their docs for how to do that (setting up can be a daunting task). The advantage of doing so is that you don't need extended permissions. However, the user will be prompted and will have the choice of not updating their status through your app.
AFAIK, there's no simple URL to set a user's status (like twitter has), just the "sharer.php", which doesn't take a status message.
It appears you'll have to authenticate as described on the REST api documentation for status.set: http://wiki.developers.facebook.com/index.php/Status.set
I couldn't find another option, and since they require you to authenticate for that method, it is reasonable to assume they'll require you to authenticate for any api that lets you update the status.
I was looking for something similar.
This seems to detail what you are looking for:
http://developers.facebook.com/docs/reference/dialogs/feed/
Try This for Facebook status update URL:
url = "https://graph.facebook.com/me/feed?access_token=" + oAuth.Token;
json = oAuth.WebRequest(oAuthFacebook.Method.POST, url, "message=" + msg);