Access Public Skydrive Content Using Live Connect REST Without Access Token - rest

According to this Microsoft api page
http ://msdn.microsoft.com/en-us/library/live/hh826522#reading_albums
, I tried to translate this browser access skydrive URL
https://skydrive.live.com/?cid=0A263A7CBEAAFB80&sc=photos#cid=0A263A7CBEAAFB80&id=A263A7CBEAAFB80%214521&sc=photos
to
http://apis.live.net/v5.0/folder.0A263A7CBEAAFB80.A263A7CBEAAFB80!4521
Since the album is shared to public, I should be allowed to access without access token.Am I missed something? Or is just using the wrong URL?
I notice I can get public profile by using this
https ://apis.live.net/v5.0/0A263A7CBEAAFB80/
And I have read the REST API
http ://msdn.microsoft.com/en-us/library/live/hh243648.aspx
, but I found it is hard to deduce the correct url format
This get all albums
https ://apis.live.net/v5.0/0A263A7CBEAAFB80/albums
REST URL also fails.

I've been looking for a guide for this as well, but just noticed that your URL appears to have an additional '/' in it. The one listed on the site is:
https://apis.live.netv5.0/%fileid%
Were you able to get this to work?

Related

OneNote API - REST & Postman

I am trying to integrate the OneNote API as part of a new application. Is it possible to use Google Chrome's POSTMAN REST Client to test the API? The OneNote API appears to be standard REST, so there should be no reason why not.
To login, I followed the documentation and did a GET request in POSTMAN to
https://login.live.com/oauth20_authorize.srf?client_id=myClientIdIsHere&scope=wl.signin&response_type=token&redirect_uri=dontKnowWhatToPutHere
Broken down, that is:
https://login.live.com/oauth20_authorize.srf
client_id=myClientIdIsHere
scope=wl.signin
response_type=token
redirect_uri=dontKnowWhatToPutHere
I tried the following based off advice from this blog: http://blogs.msdn.com/b/onenotedev/archive/2014/07/23/how-to-authenticate-with-microsoft-account-in-a-chrome-extension.aspx
https://login.live.com/oauth20_authorize.srf?client_id=myClientIdIsHere&scope=wl.signin&response_type=token&redirect_uri=https://login.live.com/oauth20_desktop.srf
When I do a GET request to this, I get HTML back, but it does not show up in the preview mode.
Am I on the right track?
The code that you are trying to execute is just the initial part of the oAuth login process.
As you have mentioned the below peice
redirect_uri=dontKnowWhatToPutHere
redirect_uri is the URL of your application. Once the authentication is success, the server will redirect the navigation to provided URL and you can proceed further from here. Just keep in mind that the URL given is as same as the one you have provided while creating the azure app. If they do not match, the server is going to simply throw an exception.
Please change the JSON to
https://login.live.com/oauth20_authorize.srf
client_id=myClientIdIsHere
scope=wl.signin
response_type=token
redirect_uri=http://localhost:8008/login
Replace http://localhost:8008/login with your application login route.

Facebook server-side OAuth 2.0 on localhost:8080 can't get access token missing redirect_uri

There are many other question related to this, but they didn't help me fix my problem.
I'm using the Facebook server-side login for a website, which I want to test locally. The path that initiates the login action is [http://localhost:8080/fblogin] (this redirects to the Facebook login dialogue, and goes from there).
I can successfully get the code, but when I try to exchange that for an access token, I get the following error:
{"error":{"message":"Missing redirect_uri parameter.","type":"OAuthException","code":191}}
I am providing the redirect_uri, url encoded and it is the same as the one I use to get the first code. Here is the url I'm using to request the access token (with the all-caps query string parameters replaced with their actual values, of course):
https://graph.facebook.com/oauth/access_token?client_id=CLIENT_ID&redirect_uri=http%3A%2F%2Flocalhost%3A8080%2Ffblogin&client_secret=CLIENT_SECRET&code=CODE_FROM_FB
I suspect this might have to do with how my app is set up on Facebook. Here are the values I have set:
Display Name: (an actual display name here)
App Domains: localhost
Contact email: (an actual email here)
Site URL: [http://localhost:8080/fblogin]
What do I need to tweak in the settings to get this to work? Or does this look correct?
By the way, if it makes any difference, I am using the Play! framework, version 2.0.1
After digging around a little more, I found that it was necessary for me to use POST when sending the request from my server to get the access token.
Interesting that using POST worked for you as this didn't for me.
In any case, did you add the query parameters using setQueryParameter()? (see How to make multiple http requests in play 2?)

how to get a facebook status updates from certain fan page?

Updated:1/27/2013
After some research I found out that I need to do a http get ..
I am using graph apis . I am using the below url .
How ever each time I am getting a bad request?
https://graph.facebook.com/1021259526/statuses&limit=20&access_token=AAAFM2GZAUaXQBAIlkFVUKxZCXs2rbZCuyoHy0n1jKucWuA8QorbdOLzJ7Wr3TUUBMrcZB6j008RjnOtwWnNJTcmzWSXZAjKeFz
I have assumed access token to be for user access token which I get every time a user logs in.
Is there any thin I am doing wrong?
I am now able to get the json data .. For any one who gets stuck here I suggest you guys to use fiddler traces to capture the https traffic an duse that url in your app....
So my mistake here was https://graph.facebook.com/1021259526/statuses?method=GET&format=json&access_token="wahtever is teh access token" ....

The url supplied is invalid Facebook RestFB

I am using Facebook Graph using RestFB. When I am trying to post a URL to Facebook -
http://localhost:8080/demo
I even tried
http://www.wannaget.com/home
This is also not working. Issue was not local or live url. Because this was working previously But now it gives me invalid URL error.
It gives Following response
INFO: Facebook responded with HTTP status code 400 and response body: {"error":{"message":"(#1500) The url you supplied is invalid","type":"OAuthException","code":1500}}
I don't understand the reason why this is happening. Everything is working fine but now I am facing this issue.
The url is not in a valid format. I guess it has to end with an extension, like "http://localhost:8080/demo.html"
A workaround that worked for me (on rails):
I was trying to post on fb the link "localhost:3000/articles/53" with that same error.
To fix it I had the route:
match 'news/article/:id/x.x' => 'articles#show'
and post successfully on fb the resultant link "localhost:3000/articles/53/x.x"
Any real solution is welcome!
The URL you provided is a for a local server running on your machine. Facebook has to be able to access that URL but it can't because it is not on the Internet - it is only accessible from your local computer.
You'll have to give Facebook a real URL that is accessible by their servers...

Facebook server-side authentication flow: is this the right "code?"

I'm using FB.login on the JS client and want to verify the user's identity on the server. So, the client gets a signedRequest from facebook and sends it to the server. The server splits on the period, and decodes the second part of the signedRequest into a json object.
What should I be using for "code" when I send my server-side request to
https://graph.facebook.com/oauth/access_token?
client_id=YOUR_APP_ID
&redirect_uri=YOUR_REDIRECT_URI
&client_secret=YOUR_APP_SECRET
&code=CODE_GENERATED_BY_FACEBOOK
My decoded json looks something like:
{"algorithm":"HMAC-SHA256","code":"2.AQCPA_yfx4JHpufjP.3600.1335646800.1-5702286|l11asGeDQTMo3MrMx3SC0PksALj6g","issued_at":1335642445,"user_id":"5232286"}
Is that the code I need? Does it need to be B64 encoded? If this isn't the code, what code should I use?
_
What I've tried:
The request I'm trying to use is:
https://graph.facebook.com/oauth/access_token?client_id=295410083869479&redirect_uri=https://squaredme.appspot.com/facebookredirect&client_secret=44f1TOPSECRETbb8e&code=2.AQCPA_yfx4JHpufjP.3600.1335646800.1-5702286|l11asGeDQTMo3MrMx3SC0PksALj6g
but this returns the error:
{"error":{"message":"Error validating verification code.","type":"OAuthException","code":100}}
I can't tell if this is because I'm using a bad code, or what. Noteably, this is running on my local dev server, and squaredme.appspot.com definitely does NOT resolve to my IP. I don't know if facebook checks that or what - I'm assuming I'd get a better error message. Thanks for any direction!
You are trying to somehow combine the two flows together and that's why things don't work well.
When facebook POSTs into the iframe with your app url and a signed request there are two options, the easy one being that the user is already authenticated and then the signed request will have all the necessary data (including a signed request), then you just load the canvas page and use the JS SDK to get an access token there as well, but in this case there's no need to use the FB.login (since it opens a popup and will automatically close it), you can use the FB.getLoginStatus method which won't annoy the user.
If the user is not authenticated then the sign request will be missing the things you need to use the graph api.
You then redirect the user to the auth dialog, and since you are loaded in an iframe you'll need to return a html response which redirects the parent window using javascript, like:
top.location.href = "AUTH_DIALOG_URL";
When the use is done (accepted or rejected the app) he will be redirected to the "redirect_uri" you added as a parameter to the auth dialog.
If the user accepted your app then you'll be getting the "code" parameter in the query string.
You then take the code, exchange it with an access token as you posted in your question, and then redirect the user back to "apps.facebook.com/YOUR_APP".
When the page then loads the user is already authenticated and you'll be getting a full signed request.
I hope this clarifies things for you, recheck the Server-Side flow it pretty much covers it all.
I also had some trouble with that, then I found the solution here in StackOverflow.
There are two kinds of "code" provided by facebook. One comes inside the signedRequest in the cookie generated by the client-side flow. The Facebook's JS SDK handles this codes and get a access token without telling us anything.
The other type of code comes attached as a query to your redirect URI (http://www.yoururl.com/index.php?code=AAAgyiaus...), when you navigate to OAuth URL (server-side flow). With this code, you go to a Token URL and get your access token.
When you are using the server-side flow, you need to indicate a redirect URI both in the OAuth URL AND in the Token URL, and they have to be exactly the same, so a missing slash or a query string can be a lot of problem.
The codes are different from each other. When you use the both things together, appears to be impossible to get a access token using the code that was inside the cookie's signedRequest.
BUT, it is not. The magic is: the code from signedRequest is associated with NO URI, so as long as the redirect_uri is a mandatory field, all you have to do is to pass it blank when you navigate to the Token URL.
So the final solution is: grab the signedRequest from the cookie, parse it in your server to obtain the code, then read the Token URL:
https://graph.facebook.com/oauth/access_token?
client_id=YOUR_APP_ID
&redirect_uri=&client_secret=YOUR_APP_SECRET
&code=CODE_INSIDE_THE_SIGNED_REQUEST
It looks like a hack, so I don't know how long it's gonna work, but it's working right now.