-
Notifications
You must be signed in to change notification settings - Fork 19
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
facebook token, now whats next #12
Comments
I understand the after facebook returns a token, we can use that to access AWS resources like S3, DynamoDB, etc... But what if i want my facebook user to maintain an account on my application (storing all his activity, points, etc,, similar to a traditional user who signed up without facebook).. Does that mean we shall create a new account in UserPool using his facebook details? |
@vvavepacket Sounds like you have a question like this: amazon-archives/amazon-cognito-identity-js#353 This library is a direct port amazon cognito identity js, but with just the SRP_A built using a bridge and with memory storage async. Basically the same exact library just speed boost for SRP_A, so any linking of accounts should be the same. Also found these: https://aws.amazon.com/blogs/mobile/announcing-your-user-pools-in-amazon-cognito/ http://docs.aws.amazon.com/cognito/latest/developerguide/synchronizing-data.html I'm currently working around the clock on my job, so I haven't had the time to put together a Facebook example and test it out. We are just using the User Pools with Cognito Federated Identities. |
If a user is logged in via FB and you got a aws session token, the user has access to several aws services with this token, but just temporary and no extra user was created. |
Cognito adds Social Identity Providers for UserPools (11 August): Here is a link to the docs: http://docs.aws.amazon.com/cognito/latest/developerguide/cognito-user-pools-social.html But there isn't any code example yet. @jmparsons do you have an idea if it can work with your lib? |
@spoeck I'd check with the guys who write the lib over at https://github.com/aws/amazon-cognito-identity-js/ this is just a react native port. |
Sorry to ressurect this one, but I'm having the same issues. I get the token from the login but where do I go from there? Help solve this one guys I plan to make a pull request after |
@MatheusParanhos I haven't had time to look into it. Hopefully someone else can chime in here. |
@jmparsons That would be sensational. Pleease someonee |
@jmparsons Any news? 🙏 |
I would say look through the amazon cognito identity issues such as this one: amazon-archives/amazon-cognito-identity-js#353 My 9 to 5 is more like a 9 to 9 and I'm on tight deadlines, so I can't build out fb and test it right now. |
this feature would be really nice to have! 💪🏻 |
Can somebody found the solution? :'( |
The AWS docs are absolutely terrible. |
My understanding is that having a Facebook login to create an user in user pool you need to use a hosted page using this library: https://github.com/aws/amazon-cognito-auth-js - and more specifically the relatively new "Federated Identities" feature. Unfortunately this library is designed for web apps, not react native. Using the hosted page in a new browser app probably would create the user, but I don't see how I can easily read the saved token / user credentials. Another option would be to use One more thing: the Facebook token can be used to fetch AWS credentials (and there are examples for this), but this seems different from integrating with an User Pool. |
@RaphiStein Any luck? |
I managed to crack this after several hours. Only a PoC so far, but logs the records in the console. Here is what works for me: // AWS.js
import AWS from 'aws-sdk/dist/aws-sdk-react-native';
import 'react-native-aws-cognito-js';
/**
* ATTENTION - I had to change the require(aws-sdk) in amazon-cognito-js source as described on
* https://github.com/AirLabsTeam/react-native-aws-cognito-js/issues/2
*/
import 'amazon-cognito-js';
// Configuration consts from .env
import { AWS_COGNITO_REGION, AWS_COGNITO_POOL_ID, AWS_COGNITO_DATASET, AWS_COGNITO_RECORD } from 'react-native-dotenv';
AWS.config.region = AWS_COGNITO_REGION;
// TODO: it's only a PoC -> move into a Component with progress indicator
export const sync_cognito = (accessToken: any) => {
AWS.config.credentials = new AWS.CognitoIdentityCredentials({
IdentityPoolId: AWS_COGNITO_POOL_ID,
Logins: {
'graph.facebook.com': accessToken,
},
});
AWS.config.credentials.get(err => {
if (err) {
console.error(err);
}
// The CognitoSyncManager DataStore must be memory
const syncClient = new AWS.CognitoSyncManager({ DataStore: AWS.CognitoSyncManager.StoreInMemory });
syncClient.openOrCreateDataset(AWS_COGNITO_DATASET, (err, dataset) => {
if (err) {
console.error(err);
}
dataset.synchronize({
onSuccess: (data, newRecords) => {
dataset.get(AWS_COGNITO_RECORD, function(err, value) {
if (err) {
console.error(err);
}
console.log(value);
});
},
onFailure: err => {
console.error(err);
},
});
});
});
};
export default AWS; Usage in the Component file: // import the function
import { sync_cognito } from '../../sync/AWS';
// after FB login
AccessToken.getCurrentAccessToken().then(data => {
sync_cognito(data.accessToken);
}); |
Hi ! Same struggle here !
this works well but getCurrentUser() returns null and the Anybody already did this with Cognito ? |
@offaxis Because you are login by facebook, not by cognito user pool, so getCurrentUser() will not return anything. |
@canhnht Yes i found it ! I prefered use integrated UI Cognito Login, witch create a user in my user pool, but i got the same problem : getCurrentUser() does not return the user ! see => amazon-archives/amazon-cognito-auth-js#62 |
Let's say we want users to sign in into our app. There are 2 ways:
1.) Signup, and login (this will create an account in User Pool)
2.) Facebook login (user will just login to his facebook account)
Now, 1.) works fine, I'm able to have users signup and login. I am having problem in 2.). I was able to get the token from facebook (I am able to integrate facebook login button in my react native app)... Now after we get the token,, I want my users to use this facebook login and just continue using the app.
How do we achieve this? Are we supposed to create a new user in UserPool programatically if users login via facebook? Or we dont have to create the account manually (I assume that once the user logins using his facebook account, the next time he will use the app, he will be remembered)?
My point of confusion is, there is no cognitoUser if we are using federated identities or facebook. Please help me clear this confusion and what would be the best thing to proceed for number 2.
The text was updated successfully, but these errors were encountered: