Authentication Firebase + auth0

I am 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 have looked through all the auth0 documentation and I have authentication working for:

Facebook, Google+, Twitter, self-registration.

Problem: The documentation is similar to the fact that I need to integrate the authentication model with Firebase, it gives me this page, and I'm not quite sure what it is now. Does anyone do this integration before and can you lead me along this path? I am new to this.

BlockquoteConfiguring Token Content

Like any other API registered in dahsboard, Auth0 issues a Firebase token through the delegation endpoint. This allows you to exchange the token for another.

The contents of the Firebase token are generated by convention, copying all the properties contained in the firebase_data attribute in the input token used in the delegation call.

You can generate them very easily using the rule:

user.firebase_data = { user_id: new Buffer(user.email).toString('base64'), company: !user.isSocial ? context.connection.replace(/\./g, '-') : null, foo: 'bar' }; 

In the above example, two user_id and company properties will be generated after the endopint delegation is called, and both will be available for Firebase.

Blockquote

+7
authentication ios objective-c firebase auth0
source share
1 answer

I did this for Javascript in the browser, and not for ios / Objective C. But in concept you need to do four things:

Customization

  • Configure your Auth0 account to enable Firebase delegation and provide a Firebase token. This part is covered by Auth0 ios / C docs objects for Firebase in the Firebase tab.
  • (optional) Create an Auth0 rule to set the properties of delegated Firebase tokens. You have it in your fragment above.

Auth0 Rule for setting Firebase marker 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 the Firebase security rules.

Authentication flow

Auth0 has a quick example that is likely to be useful to you. You need to do two things:

  • After user authentication completes successfully, make a second Auth0 request for the delegated Firebase access token from Auth0, see sample line 65 .
  • Use the new delegated token with the Firebase object using the authWithCustomToken method, see sample line 73 .
+2
source share

All Articles