Skip to content
This repository has been archived by the owner on Mar 22, 2024. It is now read-only.

Getting remote oauth token from facebook whilE IN R studio server #17

Closed
simran-k opened this issue Jun 10, 2016 · 8 comments
Closed

Getting remote oauth token from facebook whilE IN R studio server #17

simran-k opened this issue Jun 10, 2016 · 8 comments

Comments

@simran-k
Copy link

What is

The redirect_uri URL is not supported

error on facebook.

I have opted for out of band authentication and thus I have to point my browser to the url:

https://www.facebook.com/dialog/oauth?client_id=611685395673327&scope=ads_management&redirect_uri=urn%3Aietf%3Awg%3Aoauth%3A2.0%3Aoob&response_type=code

in order to get my authorization code.

Where did I go wrong?

What exactly do I need to pass into redirect_uri in the facebook application?

Since I am using R studio server, it is http://localhost:1410/ when one is working locally but it wont work with remote server.

A relevant post:https://support.rstudio.com/hc/en-us/articles/217952868-Generating-OAuth-tokens-from-a-server

@daroczig
Copy link
Owner

Sorry for the delay with my reply, this is a pretty busy week -- will look into your other ticket as well (but probably only next week). As a quick resolution for this, I suggest to do the auth on localhost as described at https://github.com/cardcorp/fbRads#creating-a-facebook-app--connect-with-oauth-token, then you can save the token and transfer to the server.

@simran-k
Copy link
Author

simran-k commented Jul 1, 2016

@daroczig : Hey, Thanks for reviewing the problem. I of course went for the solution but since it more or less feels like a hack, I would still like to know a concrete solution for the problem. That would be much appreciated.

@simran-k
Copy link
Author

@daroczig : Hi, So now, how do I refresh the token? My last token expired and now I am facing the same issue

@daroczig
Copy link
Owner

Just replied on #38. Sorry, I'm still pretty busy with other things and I still consider this ticket to be not highly related to the R package but rather to infra and how you set up your FB ads analytics environment, so could not dedicate much time into looking into the case how to auth in a server environment that you use from a client via a web browser. I hope you understand it. I'm not closing the ticket, as I might have some time later to come up with a hack for this, but no promises for the near future.

Again: you can generate the token on your localhost and copy it to the server. With standard access to the API, you can use non-expiring tokens as well, so this is a once time task.

@simran-k
Copy link
Author

"With standard access to the API, you can use non-expiring tokens as well, so this is a once time task.", I believe I am using it but the token has expired after a couple of months. Am I missing out on something here?

@daroczig
Copy link
Owner

@bjeavons do you know top of your head how to create a non-expiring token?

@bjeavons
Copy link
Contributor

https://developers.facebook.com/docs/facebook-login/access-tokens/expiration-and-extension details it but in short: Use a short-lived user token, your app ID and app secret to call from your server

GET /oauth/access_token?  
    grant_type=fb_exchange_token&           
    client_id={app-id}&
    client_secret={app-secret}&
    fb_exchange_token={short-lived-token} 

@daroczig
Copy link
Owner

Closing this, as I think getting a long-live token resolves the problem much better then trying to figure out how to auth with a local browser client and remote R session

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

No branches or pull requests

3 participants