Andrew-NZ
Andrew-NZ

Reputation: 491

Connecting Janrain social login to AngularJS

Please note that I am asking a conceptual rather than a specific question.

The question: Fundamentally, a java servlet receives a post from an external API and needs to tell AngularJS about it. What is the best way or, what are the main considerations in deciding the best way?

For background, my particular situation is with the Janrain social login API:

I want to use the Janrain social login with AngularJS. Following their examples I can successfully get all the way from AngularJS to Janrain and back to a java servlet which completes with a valid user profile. So that whole flow works.

Where I am stuck is how to get from the java servlet back to AngularJS. There seem to be several approaches such as:

  1. Deploy the Janrain javascript client (janrain-init.js) and insert an event in AngularJS as in janrain.events.onCaptureLoginSuccess.addHandler() - except I have no idea where to find a copy of janrain-init.js (yes, I've looked).

  2. Create a .jsp page as the return destination from Janrain, call java from the jsp page to swap the token for the profile and then somehow communicate the result to AngularJS. But how?

  3. Keep the return destination as the java servlet and somehow send a notification to Angular. But how?

Thank you

Update: What I have learnt...
1. The best way is to have the API notify the browser that it has completed
2. Then get flow back to AngularJS as quickly as possible
3. From AngularJS call (using http) the Java servlets for any follow-up processing

That way the flow is determined by events only.

Upvotes: 0

Views: 108

Answers (0)

Related Questions