Facebook API App Access Token cannot access Ads Data - c#

I am trying create an automated process to pull Facebook Ads data with the c# Facebook api (facebook.ddl) on a daily bases. The process needs to be fully automated so that no human intervention is needed. I was able to pull the data when using an "user" access tokens; however, the “user” access tokens expired after a short period of time (e.g., 2 hours) and required a user to confirm the request for a new token. It other words, any implementation of an user access token would prevent me from fully automating the process. Next, I tried to pull the Facebook Ads data with an "app" access token but the process failed with an error message related to security/permissions. Currently, it is my understanding that "app' access token were not design to access Facebook Ads data. Is this correct? If so, I would like to know if it is possible to pull Facebook Ads data via a fully automated process and (if it is) how to do it?

You should exchange the short exchange the short-lived 2 hour token for a 60 day long-lived token. Process is outlined here.

Related

How do I save my refresh token in my application when user doesn't log in frequently?

Updated question:
I have an application that needs to import data from an external API. This API hands out an authorization code that is valid for 10 minutes. With this auth code I can make a GET request to receive an access token and refresh token. The access token is valid for an hour.
The access tokens that are handed out needs to be shared between users of the same company.
How do I store these tokens in a secure way?
Let's say the users doesn't log in for a few days, then I don't want to have to go through the whole process with the auth code again.
So my two questions are:
Where do I save the tokens?
How should I go about refreshing the refresh token? An example could be that the users doesnt log in for 2 months, and then the refresh token has expired. Do I update it with scheduled jobs?

dropbox-sdk-dotnet: how to get a refresh token and update the access token

I'm using the Dropbox SDK for DotNet, and it is time to support short-lived Access tokens.
My use case is uncommon (web site, 'backend side'). Once the link to DropBox is made, everything should keep working unattended.
In fact, it is OK to never publish the app. Each user creates its own app in their own Dropbox account and stays on Development mode forever.
Until now, the user created the dropbox app, takes note of the App key, App secret and generates an access token directly at https://www.dropbox.com/developers/apps/info/....
With this data, the application was working fine, but Access tokens will soon be short-lived only. I already verified the like to dropbox gets broken after the generated (from www.dropbox.com/developers/apps) Access Token expires.
How can I, using the SDK and having a valid Access token, get a refresh token to be saved and utilized to get a renewed access token?
I couldn't find any way in DropboxClient.cs, DropboxOauth2Helper.cs, not the examples at https://github.com/dropbox/dropbox-sdk-dotnet/tree/main/dropbox-sdk-dotnet/Examples
It is not possible to use an access token to retrieve a refresh token. A refresh token can only be retrieved via the OAuth flow. I recommend reading the OAuth Guide for more information.
The "Generate" button on the app info page on the App Console does not currently offer the ability to generate a refresh token, but I'll pass this along as a feature request. I can't promise if or when that might be implemented though.

Using Facebook graph Api in c# windows application

I want to start with graph Api in windows application. I created a facebook app and see some articles about graph Api but unfortunately I did not understand. I want to get data like: Messages, Events, Friends, Wall posts,... from facebook.
What is the first step for this?
What is access token and if it is a constant string or changes for every request?
Do you have a very basic sample for this?
Any help will be so appreciated.
Access token will expire in 2 to 3 hours and we can extend it for 60 days. For that we need to create an application in facebook. And based on this access token will be vary and not constant.
** What is Access Token **
An access token is a random string that gives an app temporary and secure access to Facebook APIs. And access token can be created on behalf of a person, a Facebook Page or an app. The token is generated in the last step of the login flow. Facebook SDKs handle the generation and storage of tokens automatically. Apps using other methods will need to follow the login flow to create tokens.
The token stores information about permissions that have been granted as well as information about when the token will expire and which app generated it. To maintain information security, almost all API calls at Facebook need to have an access token passed in the parameters of the request.
Go through this link for Graph API

Transparently Get Facebook Profile Pictures

I'm just getting into the Graph API and am having having a hard time trying to figure out if/how I can go about showing MY profile albums on My website with out having to have the user log into facebook. I'm getting thrown off with the access token...I realize I can retreive an access token to retreive my photos if I have someone log on to the site, but I want it to be transparent, using my credentials through code (securely) some how if necessary.
How can I accomplish this? I'm looking for a general conceptual explaination, but pseudo code never hurts. Can any one clear it up for me a little?
Using:
Facebook Javascript Sdk
Mirosoft MVC
Facebook C# Sdk
There's no way, that I'm aware of, to do that.
Facebook apps treat all users the same, you can't have special privileges for your user.
If your user is public then you should be able to get all of the public using an application access token which does not expire.
If that's not the case then you have two options as I see it.
Use the server side authentication with your user, or extend a valid token (a method to replace the deprecation of the "offline_access" permission), that will get you a long lived token, about 60 days, and in that time frame you can then get your data from facebook.
Then when that expires re-authenticate in the same way and get another 60 working days, etc.
Another approach is to authenticate as yourself and then have your app save the data, then present it from your own db.
Be sure to update the data every once in a while.

Unattended DropBox .net back end access

I want my web server code (invoked from ASP.NET MVC3 site's controller) to be able to save files to Dropbox account.
I have examined two out of three .Net/Dropbox libraries and all of them require a user to "authenticate" via web-redirect to Dropbox to get a token.
Examined libs are Spring.Social.Dropbox and DropNet.
Can this authentication and upload be done via purely .net code without messing with the user's browser? Can the acquired token be saved for later use? This is theoretical question, not about particular implementation.
This is a bit of a complicated subject. As far as I know Dropbox uses OAuth, which is an authentication and authorization protocol.
General process is this:
You create authorization request token
User gets redirected, authenticates and grants permissions to your app.
You trade the request token for an access token
You must save the access token because it is used to perform actions on the users behalf
Access tokens don't usually expire and only stop working if a user revokes your application permissions.
This means the user will have to authenticate and authorize your application at least once so you can get the access token and access token secret.
After that, you are pretty much free to perform actions on the users' behalf based on the permissions granted. You must specify the access token attained by the above-mentioned process in order to perform actions.
In short, get an access token, save it, use it for requests.
Does this clarify it a bit for you?

Categories

Resources