This project is a fork of the aws-mobile-ionic-sample from aws, created to handle the token refresh when Facebook is used as Itentyty provider, i.e. to enable the Authorization Grant Flow when loggin in with Facebook.
Please, if you have suggestions, make a PR.
These prerequisites plus:
- A working Facebook app
- YARN
Assumptions:
In the following, consider the 'config file' to be the client/src/assets/aws_config.js
file
Clone this repository: https://github.com/SimoneMSR/aws-mobile-ionic-facebook-auth-grant-flow
- log in to aws console
- go to cognito -> manage my user pool
- create/go to your User Pool
- take note of your User Pool ID and set to this value the
aws_user_pools_id
variable in the config file - got to federation-> identity providers -> select facebook
- add appId and appSecret of your Facebook app
- set profile and email as user info to be read (and other if you need)
- go to federation -> attribute mapping
- map the email to be the facebook Email
- go to general settings -> app clients
- create/select your app and take note of the appID and set to this value the
aws_app_client_id
variable it in the config file - go to app client settings and scroll to you selected app
- enable all identity providers
- set the callback URL to be http://localhost:8100
- flag the Allowed OAuth Flows -> Authorization Code Grant
- flag the Allowed OAuth Scopes ->
email
,openid
- go to app integration -> domain name
- set the
aws_domain_name
variable to the domain name in the config file - got to cognito-> manage federate identities -> your identity pool
- edit identity pool
- make the
aws_cognito_identity_pool_id
variable in the config file to be you identity pool id - go to authentication providers -> facebook
- set the app id
- take note of the region of you Identity Pool and set accordingly the value of the variable
aws_cognito_region
in the config file
- go to your developer account -> you app
- add the Product 'Facebook Login'
- go to Product settings
- rembember the
aws_domain_name
variable you set beforehand in the config file - set the Redirect URI as aws_domain_name
/oauth2/idpresponse
- enable access from Mobile
- yarn install
- ionic build