Is it possible to share Facebook Test users between test apps? - facebook

We have seperate URLs for our webapp on local development and on build servers (acceptance test environment) This means that we have to setup 2 seperate Test Apps for Local and Acceptance Test.
When creating test users it seems they can only be created to be valid on only 1 test app... and I have not been able to find a way to share test users between test apps. Not being able to do this makes automated acceptanse testing a pain... as we have to have seperate testdata for Local testing and acceptance testing.
Would love to hear any suggestions on how to solve this easily?

Simple example with curl (its not possible to do it from the Dashboard)
Copy
curl -i -X GET \
"https://graph.facebook.com/v2.9/SOURCE_APP_ID/accounts/test-users?access_token=SOURCE_APP_ACCESS_TOKEN"
Paste
curl -i -X POST \
-d "uid=TEST_USER_ID" \
-d "owner_access_token=SOURCE_APP_ACCESS_TOKEN" \
-d "access_token=TARGET_APP_ACCESS_TOKEN" \
"https://graph.facebook.com/v2.9/TARGET_APP_ID/accounts/test-users"

Afaik you can only create test users for one App, but you can also create them with the API as it is explained in the Facebook docs: https://developers.facebook.com/docs/apps/test-users
Direct link to example code: https://developers.facebook.com/docs/graph-api/reference/v2.2/app/accounts/test-users

Create a test user and then use the API to connect the user to the second app.

Related

Getting Users and groups from Keycloak

I have a web application secured by Keycloak. Now I want to read all the security groups and users from keycloak in my application. Is it possible?
Keycloak has a very good documentation around the APIs.
I believe you are looking to get all the groups and users from the Keycloak. It could be as straightforward as calling any REST APIs.
You can follow this link to get all the groups from the Keycloak.
And this link to get the users based on the given search criteria.
But I would be wary of the performance implication it might have calling these APIs. Make sure to use pagination and appropriate filters for getting users.
Also, if you want, you can write a custom extension in Keycloak to serve your purpose. You can follow this link for it.
I could get the access token using the client secret key using the curl command from command line.
$curl -X POST -d "client_id=my_client" -d "username=username" -d "client_secret=c957b0ba-c421-4021-8433-764aa2fwes72" -d "grant_type=client_credentials" HOST/auth/realms/my_realm/protocol/openid-connect/token
I could also get the list of users after getting the access token
$curl -X GET HOST/auth/admin/realms/my_realm/users -H "Authorization: Bearer access-token" -H 'cache-control: no-cache'
Now, I'm thinking how can I do this from my web application.

Deploy branch on Heroku via API [duplicate]

This question already has answers here:
Redeploy Heroku app without code changes
(7 answers)
Closed 4 years ago.
I have an application set up on heroku that is automatically deployed via GitHub. That setup is great and I don't want to change anything.
There is a use case now where I need to deploy the application from time to time without code changes (the build process fetches some recent data).
I can easily redeploy an app by going to the user interface and clicking "deploy a branch". However I would love to do this via an API. I could not find anything that helped achieve this in the Heroku Platform API Documentation.
I can create a Deployment via the GitHub deployment API but that doesn't seem to trigger a deployment on Heroku.
Any leads on how I can trigger a deployment for a specific app on Heroku?
Edit: I can't really make use of the answer Redeploy Heroku app without code changes as there is no answer that offers this functionality via an HTTP API.
Heroku doesn't currently have a public API for GitHub Sync. So you will need to use their Platform API to create a build.
GitHub gives you a tar.gz under the URL https://github.com/<organization>/<repository>/archive/master.zip (you need to pass an authorization token in the headers of course).
Using curl, you can do the following:
curl -n -v https://github.com/<organization>/<repository>/archive/master.zip
That URL will be a redirection to a URL on GitHub authenticated to allow the download. Reuse that URL to create an Heroku build:
curl -n -X POST https://api.heroku.com/apps/<app name>/builds \
-d '{
"source_blob": {
"url": "<the URL fetched before>",
"version": "<the version of the code you're trying to deploy>"
}
}' \
-H "Content-Type: application/json" \
-H "Accept: application/vnd.heroku+json; version=3"
That will trigger a new build, downloading the code from GitHub. Effectively doing the same as GitHub Sync internally does.
You can also see this tutorial: https://devcenter.heroku.com/articles/build-and-release-using-the-api

running a rundeck job from a rest api

I would like to allow anyone to trigger a job I've created in Rundeck.
I can't understand from the API documentation how to do that.
Any one knows, and can give simple examples (my understanding of the subject is minimal to none)?
What I've found is of the sort:
POST /api/1/job/[ID]/run
In order to use the Rundeck API, you need to authenticate first.
Authentication can be done in two different ways:
Using a Token
Using a username and a password
Here is an example of running a Rundeck job using its API (Token based authentication)
curl -X POST http://rundeck_server:port/api/19/job/87bdc26ce-9893-49bd-ad7a-97f4c4a39196/run?authtoken=AVy8jZdcpTYOyPcOVbfcfOQmB6b92zRu --header "Content-Type:text/xml"
Explanation:
19: the API version or Rundeck installation version (19 matchs
Rundeck 2.8.2)
87bdc26ce-9893-49bd-ad7a-97f4c4a39196: Job UUID
run: Runs a job
PS: To obtain an API Token, you must first log in to the Rundeck GUI using a user account. Click on your username in the header of the page, and you will be shown your User Profile page. From this page you can manage your API Tokens.
To update the answer above, this is an example of running a job and feeding it arguments
You will need to replace hostname/API version/job UID/token
Also the current version can be used with JSON only
curl -X POST https://rundeck-hostname.com/api/41/job/7087d3b7-e454-4983-abd5-a211d21d6f27/run?authtoken=[redacted] -H "Accept: application/json" -H "Content-Type: application/json" -d '{
"options": {
"optionName":"optionValue",
}
}
'
And if you need additional arguments for running a job you can find the updated documentation at https://docs.rundeck.com/docs/api/rundeck-api.html#running-a-job

Multiple subscriptions on same Instagram realtime update

I have implemented handling subscription notifications for user media updates and it works really great. However, I cannot find a way having two subscriptions of the same type at the same time, e.g. user media updates.
Setting up a subscription is straight forward:
curl -F 'client_id=CLIENT-ID' \
-F 'client_secret=CLIENT-SECRET' \
-F 'object=user' \
-F 'aspect=media' \
-F 'verify_token=myVerifyToken' \
-F 'callback_url=http://YOUR-CALLBACK/URL' \
https://api.instagram.com/v1/subscriptions
I would like to find a solution that can publish subscription notifications to both production environment AND test environment as well. But calling the above in sequence, with one for production and one for test will only keep the last subscription.
Production: www.myservice.com/instagramcallback
Test: www.test.myservice.com/instagramcallback
Instagram real-time photo updates: https://instagram.com/developer/realtime/
EDIT
Instagram does not publish to more than one subscription.

How to run Facebook's curl codes?

Im new to php n curl.. Im going to use Facebook's OGP for my facebook app that im using in my website..I created OPG setings for publish my app activities to the users profile.
https://developers.facebook.com/docs/beta/opengraph/tutorial/
After i have setup accouring to the Tutorial(above url) they give me curl code like
curl -F 'access_token=AAACAwq1JHZA0BAA94uB50n7O71B6PmMUsFAydKBKCv1HcdJw9NwK8MZC83vL2YqUXojQ0aXH8EBjTweKHQTr4bZBKlgkOJ0nB5dBDu6A09UbI0lmXZBs' \
-F 'friend=http://samples.ogp.me/205849716166552' \
'https://graph.facebook.com/me/yalumalu:add'
and
curl 'https://graph.facebook.com/me/yalumalu:add?access_token=AAACAwq1JHZA0BAA94uB50n7O71B6PmMUsFAydKBKCv1HcdJw9NwK8MZC83vL2YqUXojQ0aXH8EBjTweKHQTr4bZBKlgkOJ0nB5dBDu6A09UbI0lmXZBs'
I don't know how to run these codes in my site..Tutorial says something else there no curl codes in tutorial that given by facebook.. I tried alot.. Someone please help me to do this..
cURL is a simple way to HTTP GET/POST/DELETE requests.
If you need to achieve similar behaviour in your site you need to choose a language that supports sending these requests.
For example you can use PHP and cURL options as well as the PHP SDK or you can use JavaScript to do the same with the JS SDK