Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#165273474 Add Social Authentication #29

Merged
merged 1 commit into from
May 8, 2019

Conversation

mwinel
Copy link
Contributor

@mwinel mwinel commented May 7, 2019

What doe this PR do?

This PR adds the implementation for social authentication.

Tasks

  • Add Facebook social authentication.
  • Add google social authentication.
  • Add unit tests.

How to test it

How to test facebook social authentication

  1. Create a developer account on facebook.
  2. Create a Facebook App with your account.
  3. On the left menu, go to Roles.
  4. Select Test Users and add a test user.
  5. Select edit and change permissions.
  6. Add email and user_friends, then update.
  7. Go to edit again and get an access token for the user.
  8. Copy the token and insert it in your postman request.
  9. Use the POST method with URL http://localhost:8000/api/social_auth/facebook/

Sample request body

{
    "access_token": "EAAEZBSd50CgMBAKU2kVZCUVycQze5hFi7qrQkPErsmUov1vuRU4uUIoqdkthwLZC2g97eSvZCB8loviLxjAYt6F8HVsB6EDTWTSOSSbUfbASb9KTVhsNkBhGhZAAJJjvmkOhYmEFdpwFJa1PiqdGZCTySpFfw9EQbt8vIKP7NULUQVtwuVzo6nfhIGyXNZBofP8UQV9S8AMVAZDZD"
}

Sample response body

{
    "email": "dnegzbrtlf_1557208083@tfbnw.net",
    "username": "Daniel Alcfeagfbiigf Baoman292",
    "token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJleHAiOjE1NTcyNDUyMzYsImlhdCI6MTU1NzI0MzQzNiwic3ViIjp7ImVtYWlsIjoiZG5lZ3picnRsZl8xNTU3MjA4MDgzQHRmYm53Lm5ldCJ9fQ.4JbP5N2HC6KK-y237DyNCRiIJU7Gt_CLt-5Gg924Wts",
    "message": "Successfully logged in."
}

How to test google social authentication

  1. Go to Google Playground.
  2. Select Google OAuth2 API v2.
  3. Select all options and Authorize APIs.
  4. Sign in, Allow, and Exchange Authorization Code for token.
  5. Copy the id_token and insert it in your postman request.
  6. Use the POST method with URL http://localhost:8000/api/social_auth/google/

Sample request body

{
    "access_token": "eyJhbGciOiJSUzI1NiIsImtpZCI6IjVkODg3ZjI2Y2UzMjU3N2M0YjVhOGExZTFhNTJlMTlkMzAxZjgxODEiLCJ0eXAiOiJKV1QifQ.eyJpc3MiOiJodHRwczovL2FjY291bnRzLmdvb2dsZS5jb20iLCJhenAiOiI0MDc0MDg3MTgxOTIuYXBwcy5nb29nbGV1c2VyY29udGVudC5jb20iLCJhdWQiOiI0MDc0MDg3MTgxOTIuYXBwcy5nb29nbGV1c2VyY29udGVudC5jb20iLCJzdWIiOiIxMDQ0NjkyNTA5MDQxODMwMDY2NDIiLCJoZCI6ImFuZGVsYS5jb20iLCJlbWFpbCI6Im5lbHNvbi5td2lydW11YmlAYW5kZWxhLmNvbSIsImVtYWlsX3ZlcmlmaWVkIjp0cnVlLCJhdF9oYXNoIjoiOUZsbFFEZF9lcDJqMk5SMGRkeFRXdyIsIm5hbWUiOiJOZWxzb24gTXdpcnVtdWJpIiwicGljdHVyZSI6Imh0dHBzOi8vbGgzLmdvb2dsZXVzZXJjb250ZW50LmNvbS8tWXhZRU5zQUUzRW8vQUFBQUFBQUFBQUkvQUFBQUFBQUFBQWMvUVdYZzBJT2dONk0vczk2LWMvcGhvdG8uanBnIiwiZ2l2ZW5fbmFtZSI6Ik5lbHNvbiIsImZhbWlseV9uYW1lIjoiTXdpcnVtdWJpIiwibG9jYWxlIjoiZW4iLCJpYXQiOjE1NTcyMzk1MjcsImV4cCI6MTU1NzI0MzEyN30.eaFInztHLki0Om8VSKI6rGosKfAzVyRxRY4dRxzZN5Q0MMRw3WaGDSCIPAeXbz_8385ssBibM5dCJmtwNc85bhqzF5deMO89Hx26TmqfCZ-ocTiLf6L34B9nEqqqy8vKGyvCIoyIT1upPIEjQyTGgmANr42QVDHFD8spRWHfentwME_xjZQ_BkRQHgb05uGBj_miTraqq9oabCBqQUwiUT0TrTJ4XcuFaqCbp_WuuD37MM6sYNlMac1_rQyiOSKaXvhrvCVWnIR7QZW8GRiSd8ifoWpRKY8dlCJyAgOuAI10efHmgIcXfTpFVmReQ3ycjgtaFrBmJWid6r1XV7h-SQ"
}

Sample response body

{
    "email": "nelson.mwirumubi@andela.com",
    "username": "Nelson Mwirumubi130",
    "token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJleHAiOjE1NTcyNDU0MzgsImlhdCI6MTU1NzI0MzYzOCwic3ViIjp7ImVtYWlsIjoibmVsc29uLm13aXJ1bXViaUBhbmRlbGEuY29tIn19.sjxPrJCjyspcCyWmtzv1dRrcNRr_fx7kH4BIgxYu31w",
    "message": "Successfully logged in."
}

How to test twitter social authentication

Sample request body

{
   "access_token": "233108415-8qH2w2uBJuBsU8tWAtoZ5ARtfpKxLyDF6jyas8zl",
   "access_token_secret": "o5srxaPcAWpqwj6ybo3ZMEjGntWdZL5QFNRJNPkB9O5Ud"
}

Relevant stories

#165273474

@mwinel mwinel force-pushed the ft-social-authentication-165273474 branch from 79a9876 to 655728a Compare May 7, 2019 09:29
@mwinel mwinel added the wip label May 7, 2019
@mwinel mwinel force-pushed the ft-social-authentication-165273474 branch 2 times, most recently from e98a17f to 48e813f Compare May 7, 2019 11:06
@mwinel mwinel force-pushed the ft-social-authentication-165273474 branch 2 times, most recently from c30c3f4 to 2d26af0 Compare May 8, 2019 12:31
@joelmugaya joelmugaya temporarily deployed to inviticus-staging-pr-29 May 8, 2019 12:47 Inactive
@joelmugaya joelmugaya temporarily deployed to inviticus-staging-pr-29 May 8, 2019 13:27 Inactive
@joelmugaya joelmugaya temporarily deployed to inviticus-staging-pr-29 May 8, 2019 13:49 Inactive
@mwinel mwinel force-pushed the ft-social-authentication-165273474 branch from 2d26af0 to b60ea54 Compare May 8, 2019 13:53
@joelmugaya joelmugaya temporarily deployed to inviticus-staging-pr-29 May 8, 2019 13:53 Inactive
@mwinel mwinel force-pushed the ft-social-authentication-165273474 branch from b60ea54 to f3602ce Compare May 8, 2019 13:55
@joelmugaya joelmugaya temporarily deployed to inviticus-staging-pr-29 May 8, 2019 13:55 Inactive
@joelmugaya joelmugaya temporarily deployed to inviticus-staging-pr-29 May 8, 2019 13:59 Inactive
@joelmugaya joelmugaya temporarily deployed to inviticus-staging-pr-29 May 8, 2019 14:02 Inactive
@mwinel mwinel force-pushed the ft-social-authentication-165273474 branch from f3602ce to 303a8b4 Compare May 8, 2019 14:10
@joelmugaya joelmugaya temporarily deployed to inviticus-staging-pr-29 May 8, 2019 14:10 Inactive
@mwinel mwinel force-pushed the ft-social-authentication-165273474 branch from 303a8b4 to 25b293b Compare May 8, 2019 14:17
@joelmugaya joelmugaya temporarily deployed to inviticus-staging-pr-29 May 8, 2019 14:17 Inactive
@mwinel mwinel force-pushed the ft-social-authentication-165273474 branch from 25b293b to 09218b9 Compare May 8, 2019 15:02
@joelmugaya joelmugaya temporarily deployed to inviticus-staging-pr-29 May 8, 2019 15:02 Inactive
- Add facebook social authentication
- Add unit tests
Copy link
Contributor

@engjames engjames left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM nice work @mwinel

Copy link

@archibishop archibishop left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mwinel LGTM I am merging this.

@archibishop archibishop merged commit 9ea37b4 into develop May 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants