How to post client facebook ad by facebook ad api? - c#

I have been working in Facebook ad API. I am able to create abs in sandbox mode as well live mode. Our application is approved. I am getting a strange issue when I try to create ad for my facebook pages its created but when any other user tries to create ad its giving error message like
"{"error":{"message":"Unsupported post request. Object with ID 'act_facebookadaccountid' does not exist, cannot be loaded due to missing permissions, or does not support this operation. Please read the Graph API documentation at https://developers.facebook.com/docs/graph-api","type":"GraphMethodException","code":100,"error_subcode":33,"fbtrace_id":"B27E15+gMhB"}}"
We have taken following permission
business_management
manage_pages
Ads Management
Basic Access
My main aim is my customer can connect with our app they can select page for whom they want to run ad and create ad using our app.
Please help me to sort out this

This may have to do with your access level? You need Standard access so any ad account may be used. Otherwise you are limited to the max. 25 ad accounts you specify in the Ads API account configuration tool.
https://developers.facebook.com/docs/marketing-api/access/#limits

Related

How to get my Username in C# Code in Azure Web App while logged in with Azure Active Directory?

I have an Azure Web App, where you sign in with Azure AD. Now I need to show the my own Name form AD on the Website, while logged in. Is there any way to get my Username in the C# Code?
There is a Tutorial, where you connect to Azure Graph to get your username.
https://learn.microsoft.com/en-us/azure/app-service/scenario-secure-app-access-microsoft-graph-as-user?tabs=command-line
This Tutorial doesn't work, because you have to change some Settings("additionalLoginParams") in ResourceExplorer. When you try that, you get an error, that its not possible, because you use auth v2.
There is also an other Tutorial, where you access the Graph, as well. But there you access the whole Azure AD Userlist and its not possible to define, which of the users is me.
https://learn.microsoft.com/en-us/azure/app-service/scenario-secure-app-access-microsoft-graph-as-app?tabs=azure-powershell%2Ccommand-line
You can get the name from HttpContext.User.Identity.Name.
Please see this link for more details: https://learn.microsoft.com/en-us/dotnet/api/microsoft.aspnetcore.http.httpcontext.user?view=aspnetcore-5.0

Can I avoid registering my app in Azure when using MS Graph?

I am missing something important here! I just don’t know what to ask for. Maybe I’m getting it all wrong, so feel free to send me in another direction.
To keep things simple – let’s assume that I want to build an app in C# that anyone can download and install on their PC.
The app should be able to read and make changes to the current users Outlook 365 calendar.
So far, I’ve learned through the MS Graph Explorer, that I can use rest calls to manipulate data in my own calendar. Sure – it requires that I login before I can use my own data rather than “demo” data.
I’ve searched for tutorials on how to build Graph applications, to go with the same approach as the MS Graph Explorer. But every tutorial I’ve see so far requires me to register the app in Azure before it will work.
What I don’t understand is – how can the login on the web page with MS Graph Explorer give me access to my calendar without it being registered in my Azure account?
Like – if I create an app as described above – how can it work in any installation if it was not registered in the users Azure portal?
What am I missing?
Basically I’m asking how to replicate the authentication method that is used on the web page with the MS Graph Explorer.
MS Graph Explorer, like the app you would need to register, is a multi-tenant application.
When you register an app, you can choose if it allows sign in from only the current tenant, from any tenant, or from any tenant and personal MS accounts.
So you do need to register the app, but only in your AAD tenant.
Then when you authenticate the user in the app, you use one of these as the authority:
https://login.microsoftonline.com/common: allows authentication from any AAD tenant and with personal MS accounts
https://login.microsoftonline.com/organizations: allows authentication from any AAD tenant (no personal MS accounts)
The user will then authenticate to their own home tenant and will be required to give consent to scopes required by your app (e.g. permission to read/write calendar data for current user).
After consent, a service principal/enterprise app is created in the user's tenant (if it is an AAD user).
This SP is the local representation of the app.
You can read more about multi-tenancy in the docs: https://learn.microsoft.com/en-us/azure/active-directory/develop/single-and-multi-tenant-apps

Get SharePoint user detail via Azure Chat bot

I'm developing a chat bot using bot framework form flow to embed in SharePoint online for service ticket creation.
I have used iFrame for to attach it on share point online. Now I need to get the user name & Email ID of the user logged-in the share point site. Since the bot is hosted on Azure and using iFrame the below commands not applicable here
activity.ChannelId;
activity.From.Id;
activity.From.Name;
From what i understand that you want to get user' name and email ID from sharepoint online sites.
I suggest try graph API to get your user'data.
GET https://graph.microsoft.com/v1.0/users?$select=displayName,mail,userPrincipalName
References are here
For anonymous user or get access without user, you can try use the OAuth client credentials grant flow to get an access token.
Register your app.
List itemConfigure permissions for Microsoft Graph on your
app.
Get administrator consent.
Get an access token.
Use the access token to call Microsoft Graph.
For more detailed steps on how to register, here is the link.

Getting the AD Groups using ADAL within an iOS Xamarin app

Is there a possible framework or connection to make to make it possible to receive the AD Groups an user is part of using Azure AD from a Xamarin iOS app.
I have the authentication part down using ADAL but in the iOS app I want to display certain parts or hide certain parts based on what roles the user has within the domain.
To get group information you should use the Microsoft Graph. You'll need to add some delegated permissions to your app in the Azure Portal, then sign in the user, and finally can make an http request to get the group info providing the access token from the authentication.
The endpoints that will be useful for doing group operations are listed out here.

Outlook REST API - How to retrieve a User Photo

I would like to get the photos of my users from outlook and store them in my database. I want it to be done automatically by the programm with no user interaction required, because i know their email and password.
I´m trying to use this guide:
https://msdn.microsoft.com/en-us/office/office365/api/use-outlook-rest-api#UseaclientlibrarytoaccesstheOutlookRESTAPIGetanaccesstoken
I have already registered my website (.NET MVC 5), but I don´t know how to do the authentication and access token part, because half of the links of the guide don´t work and i can´t find any helpful tutorial / code snippets somewhere else.
I´m deeply grateful for any help.
Instead of using Office 365 REST API, we can use the Microsoft Graph.
And since you don't want to the user participate in the authentication, you can using the Client Credentials Grant Flow which permits a web service (a confidential client) to use its own credentials to authenticate when calling another web service, instead of impersonating a user.
Here is the REST API to get the photo for a specific user for your reference:
GET:https://graph.microsoft.com/v1.0/users/user1#yourdomain.onmicrosoft.com/photo/$value
The app requires one of the following scopes to request the photo of user:
User.Read; User.ReadBasic.All; User.Read.All; User.ReadWrite.All; User.Read
And refer to here to register the app using the Microsoft Graph API.

Categories