How to use the service oauth (DF 2.0)


#1

I’m doing some tests in the dream factory 2 and spotted the possibility of setting up a service (in dream factory panel) of oauth (twitter, facebook, github and google).

I set up initially with Facebook but does not have anything in api_docs.

Is there any reference document to use this service?


#2

I recommend checking out the Facebook OAuth tutorial.


#3

Hi

Thank you, I managed to start the integration of my app.

I could configure the service and already with the vendor code (Facebook).

My question is as to how to complete the field query_string_from_callback_containing_authorization_code_and_service_name the URL below.

POST
https://your-url/api/v2/user/session?oauth_callback=true&{query_string_from_callback_containing_authorization_code_and_service_name}

Thanked.


#4

After a few more hours of analysis could access the url.

If it is like this:

https://your-url/api/v2/user/session?oauth_callback=true&service=facebook&code={code_returned}


#5

Hi - I am having the same issue I believe, but your solution didn’t work for me. Is there an update on this? Please see my calls below:

curl -i -k -X POST http://127.0.0.1:8080/api/v2/user/session?service=facebook

return a facebook location i.e.

https://www.facebook.com/v2.5/dialog/oauth?client_id=1234567890&redirect_uri=http%3A%2F%2F127.0.0.1%3A8080%3Fservice%3Dfacebook&scope=email&response_type=code

Once I sign in on facebook I get sent here:

http://127.0.0.1:8080/test?service=facebook&code=AQC6TrMuHaNYzf5zWjM6oiFMkMsySyTH7TYXyvVj3WtdoZ4xOuo7HSief7nLtAhA3sybkITKhx0JuJ-n0tduKasApz0a3w_T5xAp_BwE-SftS4Z7DjjQ7zIQjRkorXCBHlYSm4gtBf449dAApiTDO8CL2gZ9VM1qCAtwDpAoGRhdPrbgBuWua8DZ2Eki-gfDL869tzS4dYzoLTrs_NrRbSXpM27YvhQmQlC6tfQ0NU2mynSSeuh81p7A165_kE7FkEZyFH92Okex1G6dPkjE1Yw7lMf93SY0QvSNKIC_OWHu_tjmVuCQRu6K42tUulVFVIs#_=_

I then take the code and service and call:

curl -i -k -X POST http://127.0.0.1:8080/api/v2/user/session?oauth_callback=true&service=facebook&code=AQC6TrMuHaNYzf5zWjM6oiFMkMsySyTH7TYXyvVj3WtdoZ4xOuo7HSief7nLtAhA3sybkITKhx0JuJ-n0tduKasApz0a3w_T5xAp_BwE-SftS4Z7DjjQ7zIQjRkorXCBHlYSm4gtBf449dAApiTDO8CL2gZ9VM1qCAtwDpAoGRhdPrbgBuWua8DZ2Eki-gfDL869tzS4dYzoLTrs_NrRbSXpM27YvhQmQlC6tfQ0NU2mynSSeuh81p7A165_kE7FkEZyFH92Okex1G6dPkjE1Yw7lMf93SY0QvSNKIC_OWHu_tjmVuCQRu6K42tUulVFVIs#_=_

But I get the following error message (short):

Login request is missing required email.

Any input is helpful! Thanks!


#6

This is a cURL limitation, not processing/passing the special characters in the code you’re passing. Wrapping it in single quotes should resolve this. E.g.,

curl -i -k -X POST 'http://127.0.0.1:8080/api/v2/user/session?oauth_callback=true&service=facebook&code=AQC6TrMuHaNYzf5zWjM6oiFMkMsySyTH7TYXyvVj3WtdoZ4xOuo7HSief7nLtAhA3sybkITKhx0JuJ-n0tduKasApz0a3w_T5xAp_BwE-SftS4Z7DjjQ7zIQjRkorXCBHlYSm4gtBf449dAApiTDO8CL2gZ9VM1qCAtwDpAoGRhdPrbgBuWua8DZ2Eki-gfDL869tzS4dYzoLTrs_NrRbSXpM27YvhQmQlC6tfQ0NU2mynSSeuh81p7A165_kE7FkEZyFH92Okex1G6dPkjE1Yw7lMf93SY0QvSNKIC_OWHu_tjmVuCQRu6K42tUulVFVIs#_=_'

#7

Hi,

I am not able to follow this workflow here. What I have done so far:

  • created a service for Google and Facebook OAuth
  • created a role which has access rights for everything
  • downloaded and installed the JS demo app AddressBookForJavascript and run it in apps

What do I want to achieve?
One of these:

  • Login in Dreamfactory with FB or Google
  • Login in the demo app
  • Access SOMETHING like …/api/v2/user/session

What works so far is, that when I click on the login button for Google on the DF login page, I am redirected to Google, where I can grant the access. I am redirect to whatever I configured as redirect_url (e.g. …/files/AddressBookForJavascript/add_javascript/index.html?service=goolge or …/?service=google or /api/v2/user/session?service=google)

In the redirected url the adress contains infos like code and state session_state and authuser=0. But I am not logged in.

In my opinion, when I got redirected back to DF after granting the request in Google, DF should take the grant token and exchange it in an access token, which does not seem to happen.

Also the curl example above is not working for me.The first three steps are easy, but how do I login in in Facebook or Google with curl? I have taken the Google Location and used it in a browser, acceprted it and have taken the code from there and continued with the next crul step, but same result, I have no access to …/api/v2/user/session?service=google, DF complains that no session is set in this case.

Any advice what I can check for using OAuth in DF to give access rights to users? Just some mor Infos I am using the Bitnami stack of DF 2.1 and I have not configured any “Service Definition” with Swagger. I am sticking to the Facebook docu and to to posted comments on this page.


#8

The BitNami stack for DF 2.1.0-4 has not set the CA root certificates in PHP. Copy n pasting the certs and declaring the file location in php.ini fixed the issue.