I'm working on an objective-c iOS app. I want to use auth0 for authentication ( https://auth0.com/ ) and I want to use Firebase for the database backend.
I've gone through all the auth0 documentation and I've got authentication working for:
Facebook, Google+, twitter, self registration.
The problem: The documentation kinda falls off at the point where I need to integrate the authentication model with Firebase, it gives me this one page and I'm not really sure what to now. Has anyone does this integration before and can you lead me down this path? I'm kinda new at this.
BlockquoteConfiguring Token content
As with any other API registered in the dahsboard, Auth0 will issue a Firebase token through the Delegation endpoint. This allows you to exchange a token for another one.
The contents of the Firebase token are generated by convention, copying all properties contained under the firebase_data attribute in the input token used in the Delegation call.
You can generate these very easily with a rule:
user.firebase_data = {
user_id: new Buffer(user.email).toString('base64'),
company: !user.isSocial ? context.connection.replace(/\./g, '-') : null,
foo: 'bar'
};
In the example above, the two properties user_id and company will be generated after calling the delegation endopint, and both will be made available to Firebase.
Blockquote
I have done this for Javascript in the browser, not ios/Objective C. But in concept, you need to do four things:
Setup
Auth0 Rule for setting Firebase Token properties:
user.firebase_data = {
user_id: new Buffer(user.email).toString('base64'),
company: !user.isSocial ? context.connection.replace(/\./g, '-') : null,
foo: 'bar'
};
The properties you set here will be available in Firebase security rules.
Authentication Flow
Auth0 has a swift sample that seemed likely to be helpful to you. You need to do two things:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With