Internal Server Error while adding user to MS Teams - azure-ad-graph-api

My requirement is to add a user to MS Teams via Rest API. So I am using endpoint and parameters:
https://login.microsoftonline.com/********/oauth2/v2.0/token
Body:
'#odata.type':'#microsoft.graph.aadUserConversationMember'
'roles':'[]'
'user#odata.bind':'https://graph.microsoft.com/v1.0/users('*************')
This threw me "InternalServerError". I have no idea why I am getting this error. The complete error looks like:
"code": "InternalServerError"
"message": "Failed to execute request."
Did anyone face the same scenario I am totally confused. How to get rid of it?

I tried to reproduce the same in my environment and I was able to add user to MS Teams like below:
I granted TeamMember.ReadWriteNonOwnerRole.All permission to the Application like below:
I generated access token via Postman with Client_Credential Flow by using parameters like below:
https://login.microsoftonline.com/mytenant_id/oauth2/v2.0/token
client_id=client_id
&client_secret=client_secret
&grant_type=client_credentials
&scope=https://graph.microsoft.com/.default
To add user to MS Teams, please use the below endpoint:
POST https://graph.microsoft.com/v1.0/teams/ID/members
'#odata.type':'#microsoft.graph.aadUserConversationMember'
'roles':'[]'
'user#odata.bind':'https://graph.microsoft.com/v1.0/users('ID')
Response:

Related

How to get Azure AD Refresh token with Postman?

I try to get Refresh token with Postman using the following data:
and get a response:
What is wrong I do?
You need to provide the scope as https://storage.azure.com/user_impersonation instead of https://storage.azure.com/.default.
I tested the same in my environment and faced the same issue as well as you can see below:
As a Solution , I changed the scope as I have mentioned and I was successfully able to get the token and test the same for your requirement as well.
Note:
Please make sure to add callback_url that postman uses (i.e. https://oauth.pstmn.io/v1/callback) in the reply url of the Azure AD app as shown below:

Xero API Reports endpoints unauthorised

I'm trying to make some GET calls through Postman to the following endpoint:
https://api.xero.com/api.xro/2.0/Reports/BalanceSheet
getting this error:
{"title":"Unauthorized","status":401,"detail":"AuthorizationUnsuccessful","instance":"674c99d2-0ae3-4940-b23b-aec74cef79ea"}
The docs say this is a user roles issue, and suggests "view reports" access is off, but I'm pretty sure that's all set up correctly:
screenshot of user role options
It works fine through the API previewer, so I can't see what I'm missing.
Any help?
If it makes a difference, I'm using Oauth2.0 route.
You'll likely be missing the accounting.reports.read scope.
During the authorisation process, when you direct your user to the https://login.xero.com/identity/connect/authorize... url, try including accounting.reports.read in scope query parameter (along with your existing scopes, of course).

How do I get the campaigns list through the ads API on Facebook?

I am trying to get the campaigns list from the Graph API Explorer. I'm using the request found at https://developers.facebook.com/docs/marketing-api/reference/ad-account/campaigns/.
GET /v2.8/{ad-account-id}/campaigns HTTP/1.1
Host: graph.facebook.com
I'm' business manager and admin of the page used for ads. I found the AD_ACCOUNT_IDs using the following request on the Graph API Explorer.
GET /v2.8/me/businesses HTTP/1.1
Host: graph.facebook.com
I choosed the one which had the higher privileges.
The error reported when submitting the first request for campaigns is:
{
"error": {
"message": "Unsupported get request. Object with ID '1015359838XXXXXX' 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,
"fbtrace_id": "DLyfwGbM8fi"
}
}
What's wrong?
Thanks in advance,
Mattia
#Ryan's answer saved my day. It may sound stupid/silly but I was doing this mistake and I was just stuck at it.
Going through the FB docs for using the Marketing Apis.
I was trying to build the custom audience, this is how the curl request looks like -
One of the basic things to keep in mind while using the Marketing API is, almost all the APIs ask for these two things -
1) ACCESS_TOKEN
2) AD_ACCOUNT_ID
For people who are just starting with the FB Marketing API or somehow stuck in finding these values, I will just tell you how to get these values, so that you don't have to waste your time as I did.
So for getting the ACCESS_TOKEN, go to your app dashboard then click Add Product and then select Marketing API. Once you added the product, this is how the screen should look like -
Now just check the permissions and click on the Get Token button, a token would be generated. Just copy the token in some file and save it.
Now for getting the AD_ACCOUNT_ID value, just go to the Adverts Manager page -
The number that is written inside the red box in you Adverts Manager page is your AD_ACCOUNT_ID.
The final step would be to go back to you app dashboard again, Settings > Advanced
Click on Ads API and then enter the AD_ACCOUNT_ID here. Thats it, you have finished the Access and Authentication process for using the marketing API via your App.
Now comes the part where I was doing the silly mistake. The curls request looks like this -
curl \
-F 'name=My new CA' \
-F 'subtype=CUSTOM' \
-F 'description=People who bought from my website' \
-F 'access_token=<ACCESS_TOKEN>' \
https://graph.facebook.com/v2.8/act_<AD_ACCOUNT_ID>/customaudiences
First I replaced ACCESS_TOKEN with its value.
Then instead of replacing only the <AD_ACCOUNT_ID> I replaced the whole string act_<AD_ACCOUNT_ID>, with the AD_ACCOUNT_ID value.
So I was getting this error while making request to the API which was -
{"error":{"message":"Unsupported post request. Object with ID '120574219' 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,"fbtrace_id":"YsSvKKwgLMQ"}}
I don't know why I made this mistake but I am sure this is one of the common mistake others are doing too. Since the response from FB was misleading, I wasted a lot of my time in understanding and reading on the API permissions and authentications.
Hope this article was helpful and save your time.
I similarly was having problems trying to retrieve a list of all campaign IDs within an ad account.
I already am able to retrieve campaign data by ID, so I obviously have permissions already.
But the Facebook error message is misleading.
When retrieving an ad account (in order to then display its campaigns or whatever you want within it), you need to retrieve by its ID prepended with 'act_'.
E.g you could request /act_123456789000001234/campaigns instead of /123456789000001234/campaigns.
Thanks so much to #Jan Sommer at https://stackoverflow.com/a/39974857/470749.

cloudkit JS API authentication

Ok, I have a working cloudkit container that I am currently using as a database for my app. Now I want to try using the cloudkit API service. In the API access section, I just add a new token. this is the overview of my simple set up:
I tried using Postman to make one POST call, trying to see if my structure of my API call is right. my cloudkit container name is iCloudkit.izzuddin.CoffeeApp, and the records name is Cafe, so this is how I create the api call:
cloudkit.com/database/1/iCloud.izzuddin.CoffeeApp.Cafe/-development/public/records/modify?NewToken=031c663b3314f16ff3ee04719894b6f4e17132ad315eae27fa3e4374fd0b4e81
this is the returned value:
{
"uuid": "737d61ec-a668-4386-9512-b2ec05a8a394",
"serverErrorCode": "AUTHENTICATION_FAILED",
"reason": "no auth method found"
}
Can anybody who have experience explain how to structure the api call? thanks in advance.
Try:
https://api.apple-cloudkit.com/database/1/iCloud.izzuddin.CoffeeApp.Cafe/development/public/records/modify?ckAPIToken=031c663b3314f16ff3ee04719894b6f4e17132ad315eae27fa3e4374fd0b4e81
This should return 421 response AUTHENTICATION_REQUIRED with a redirectURL which you can use for signing in.
The next steps depend on what kind of app (web app / server to server / native) you want to build.
CloudKit Web Service needs not only your API token, but also needs [Web Auth Token], which represents the users.

Facebook Login using scribe

I'm using scribe to get user id, however I get this error:
OAuthConnectionException: There was a problem while creating a connection to the remote service.
I follow this example enhanced with javax filters (to get the parameter code correctly)
https://github.com/fernandezpablo85/scribe-java/blob/master/src/test/java/org/scribe/examples/FacebookExample.java
I also tried doing things manually and i got the access token which looks somehow like this ( i changed it a bit ) CAAHZCFE7YllgBAAZAenKbvZBrMZAZBkDGgydU2vAekwsM1V0StpZAgHXukEYWIDSpc5ZCXc4LB6suFeaPagcpj2ju6ayvAgrxYttvCQg9i7ZAdcF2ZCvhMNqTddsDUkNq1c1cX47U9KwutS5t6xpbV0cRabaVpgZCZAo4ZCTEtgckFmMajsb3zYWTH9LEfKj3CgcJ39lD2x1yRoXyAds0lKARmHZC
and while asking for user id like this:
https://graph.facebook.com/me?access_token=CAAHZCFE7YllgBAAZAenKbvZBrMZAZBkDGgydU2vAekwsM1V0StpZAgHXukEYWIDSpc5ZCXc4LB6suFeaPagcsj2ju6aYvYgrxYttvCQg9i7ZAdcF2ZCvhMNqTddsDUkNq1c1cX47U9KwutS5t6xpbV0cRabaVpgZCZAo4ZCTEtgckFmMajsb3zYWTH7LEfKj3CycJ39lD2x1yRoXyAds0lWLRmHZC%20,%20458856e03b909f426ec5d3791f0af466?fields=id,name
I get Malformed access token.
Do you have any suggestions regarding what I am doing wrong?
The URLs are the same, dunno what my mistake is :/