Authenticate with Soundcloud without having to open a popup everytime - soundcloud

I'm having a lot of trouble with connecting to the spotify api on my mobile app.
I have been able to successfully able to get a token with this url:
"https://soundcloud.com/connect?client_id=" + client_id + "&response_type=token&redirect_uri=" + encodeURIComponent(redirect_uri) + "&state=" + Spotify.State + "&scope=" + encodeURIComponent(scope) + "&display=" + display;
However, this requires the user to click on connect every time they log into the app. Is there not a way to only have them authorize the app once?
I'm assuming that's what /oauth2/token is for, but when I change my &response_type=token to &response_type=code (above) so that I can pass the code into /oauth2/token it returns a redirect error (works fine with token).
I've looked around for samples but they are hard to come by. Any help would be greatly appreciated, even a point in the right direction.
I'm referring to the HTTP API guide (https://developers.soundcloud.com/docs/api/reference). I don't want to use a javascript plugin.

Related

Facebook access user info if they are not logged in

Ok, so what I am trying to do is a bit odd, so I can't find anything that gives me even a remote idea about how to do this.
I need to access my personal profile posts:
FB.api("/" + myPersonalUserId + "/feed", {limit: 5}, function(data){
console.log(data);
// do stuff with my user info
});
in order to display them on my personal webite, similar to a dynamic blog. But I want it to automatically retrieve these posts without my having to be signed in on each computer that wants to view my site.
Before you get sidetracked on the init, I am using an app and app id that my personal user account has verified access to all permissions.
I know it will require the use of an access token, but how do I get a valid access token without being logged into that computer?
Honestly, I'm starting to question if it is even possible, but if anyone knows how I could accomplish this, that would be awesome!
The best way to achieve this is to just cache the data in your own database and refresh it whenver the user uses your App again.
If that´s not good enough, you have to generate and store an Extended User Token. How to create one is explained in the docs:
https://developers.facebook.com/docs/facebook-login/access-tokens
http://www.devils-heaven.com/facebook-access-tokens/
Extended User Tokens are valid for 60 days, there is no User Token that is valid forever. And you should never use Tokens directly on the client, because some user could just copy it from the source. Tokens are meant to be secret, so use it on the server only. You don´t need to use the PHP SDK, a simple CURL call to the Graph API will do it:
https://graph.facebook.com/[your-app-scoped-id]/feed?access_token=[extended-user-token]
Ok, so I found a solution similar to the one above, but offers a permanent access token.
first, build a url:
url = 'https://graph.facebook.com/v2.5/' + {app user Id, not public Id} + '/feed';
url += '?access_token=' + {app Id} + '|' + {app secret};
url += '&fields=id,name,message,full_picture,created_time'; // these scopes should be approved by corresponding user
url += '&limit=5';
then run it by calling a simple ajax request. These variables should be served from the server through ajax, not hardcoded on the client

Facebook dialog share (redirect_uri URL is not properly formated

I have done a huge amount of research regarding this issue but non of the answers worked for me.
I have created my facebook app and got the APP-ID now when I am constructing the URL to share a test image on facebook wall I keep getting this error
This dialog has been passed a bad parameter.
API Error Code: 100
API Error Description: Invalid parameter
Error Message: redirect_uri URL is not properly formatted
My constructed URL is
www.facebook.com/dialog/feed?app_id=' + '[MYAPPID]' + '&display=popup&caption=Check out this picture' + '&link=' + '[MYAPP].herokuapp.com/assets/wolf-391302847666d53202dab51e1ea4d8a8.jpg' + '&redirect_uri=' + '[MYAPP].herokuapp.com/' + '&picture=' + '[MYAPP].herokuapp.com/assets/wolf-391302847666d53202dab51e1ea4d8a8.jpg' + '&name=' + 'wolf' + '&description=' + 'wolf_description'
As it was prompted in one of the answers, I have created a website platform in my facebook app and added
[MYAPP].herokuapp.com/ to both site URL and APP domains.
I am also getting a warning while using an facebook debugger toll although I don't believe this causes the problem
he 'og:url' property should be explicitly provided, even if a value can be inferred from other tags.
Any help is appreciated.
Thank you.
Never mind. I was having a type. Sorry for the false alarm.
Cheers.

facebook - how to get a new authorization code for an access token

I've read through the documentation and I don't understand how to get the new code, I was doing this to get a token to read the feed for a site I'm an admin on:
https://graph.facebook.com/oauth/access_token?client_id=" + sClientID + "&client_secret=" + sSecret + "&redirect_uri=" + sRedirectURI + "&code=" + sCode;
and then:
"https://graph.facebook.com/" + sUser + "/accounts?" + sToken;
To get the feed.
It's telling me:
{
"error": {
"message": "This authorization code has been used.",
"type": "OAuthException",
"code": 100
}
}
I know I need a new authorization code but cannot find the method to call to get one in the documentation. Alternatively, is there another way to get this feed?
STEP 1:
Please open your browser, type the following URL and hit.
https://www.facebook.com/v8.0/dialog/oauth?client_id={app_id}&redirect_uri={redirect_uri}
STEP 2:
Let's assume your {redirect_uri} = https://www.abc.co.in/.
Then you will receive new authorization code with the following format in the URL itself.
https://www.abc.co.in/?code={get_new_auth_code_here}
STEP 3:
Get the access token by the following URL with said new authorization code.
https://graph.facebook.com/oauth/access_token?client_id={app_id}&client_secret={app_secret}&grant_type=authorization_code&redirect_uri={redirect_uri}&code={newly_received_auth_code}
Cheer!
You may need to re-read the login documentation: https://developers.facebook.com/docs/facebook-login/login-flow-for-web-no-jssdk/
You use the code one time only, and exchange it for an access_token - you then use the access token to make API calls on behalf of your users.
When the token expires (in approx 60 days) or the next time the user comes back to your app, you send the user through the login flow again, get a new code, and exchange that for a new token which will be valid for up to 60 days

How to publish to a facebook wall as a different person

I maintain an asp.net website and have a requirement to publish to the businesses facebook wall as the business.
We set up a facebook app to do so.
So what happens is after a user clicks a button on the website the program calls facebook with scope=publish_stream,offline_access,manage_pages parameter
Facebook returns a code
We call facebook again with something that looks like this
string.Concat("https://graph.facebook.com/oauth/access_token?client_id=" + facebookPostClientId,
"&redirect_uri=" + "blah.aspx", "&client_secret=" + facebookPostSecret, "&code=" + code )
Facebook returns an access token.
We then call facebook to get all the accounts with something like this:
https://graph.facebook.com/" + facebook_user_id + "/accounts?access_token=" + accessToken;
We then loop throught the accounts until we find the correct one and call facebook again with something like
https://graph.facebook.com/" + userName + "/feed?&access_token=" + accessToken + "&picture=" + picture + "&name=" + "Studentcard - Deal" + "&link=" + link + "&message=" + message + "&caption=" + caption + "&from=" + userName + "&to=" + userName;
It works after a fashion. IF the owner of the business who created the facebook app is logged on to facebook, then the processing works.
If anyone else is logged on then it doesn't.
The reason being that the bit where we call facebook to get all th accounts only works when the business owner is logged on to facebook.
I tried inserting the business owners facebook id inbto the code instead off the logged on users, but it doesn't work.
So what do I do? Is this the wrong way to go about this?
I realise this maybe a bit long winded, but I am new to facebook and am providing as much information as I think necessary.
Thanks in advance
Niall
The reason being that the bit where we call facebook to get all th accounts only works when the business owner is logged on to facebook.
Separate this part of the process. Get all the accounts, and then cache them in your database. Whenever you fail to get the accounts, just use the cached information and proceed normally (otherwise update the DB and proceed normally).

What's the mobileish connect url of Facebook connect?

I use the following URL setting to authorize Facebook login. But the page for Application Authorization is webish, and not mobileish.
webview
.loadUrl("http://www.connect.facebook.com/login.php?return_session=1&nochrome=1&fbconnect=1&extern=2&connect_display=popup&api_key="
+ FConnect.API_KEY
+ "&v=1.0&next="
+ FConnect.SUCCESS_URL
+ "%3Ffb_login%26fname%3D_opener&cancel_url="
+ FConnect.CANCEL_URL
+ "%23fname%3D_opener%26%257B%2522t%2522%253A3%252C%2522h%2522%253A%2522fbCancelLogin%2522%252C%2522sid%2522%253A%25220.741%2522%257D&channel_url="
+ FConnect.XD_RECEIVER);
As you see this is webish, as I had to scroll to the middle,
alt text http://img100.imageshack.us/img100/2100/facebookconnect.png
Do you know the address to get a mobileish App authorization page?
According to the Facebook developer wiki, it says that you have to set your display parameter to "wap" if you're on the mobile.
I guess you would have to check if the user is on a mobile or a PC. If on a mobile, change the display parameter to "wap", else keep it to "pop-up".

Categories