Redirect user after Authorisation

23 views
Skip to first unread message

Pranav Bhatnagar

unread,
May 19, 2014, 8:52:12 AM5/19/14
to magellan-acti...@googlegroups.com
Hi,

I have successfully implemented the authorisation but got stuck in redirecting the user after authorisation back to my domain. 

Currently what happens at the time of authorisation is a user fills in there username and password and after that we get there access token. The user's access token comes here-> https://active-api.magellangps.com/ , which means we can't save the access_token as we do not have the access to that page and the process also ends on Magellan GPS page. I wanted to know if it's possible to redirect the user back to our website with the access_token of the user.

Actual process: Login to authorise(www.example.com) >> validates on Magellen and if correct produces the access_token >> ends

Expected process: Login to authorise(www.example.com) >> validates on Magellen and if correct produces the access_token >> Redirects to www.example.com with the access_token either


Can you please guide me through.

Chris Lukic

unread,
May 20, 2014, 8:32:58 AM5/20/14
to magellan-acti...@googlegroups.com
Hi Pranav,

The api auth process I think is perhaps more straight forward than you think. 

As I understand it there's no OAuth 2 style interface. You only need to make an HTTP GET request to the magellan endpoint with the username and password in the query string, and you should receive the auth token in the the response body in either json or xml. You can test this pretty easily from the browser.

Cheers
Chris

Pranav Bhatnagar

unread,
May 20, 2014, 8:56:51 AM5/20/14
to magellan-acti...@googlegroups.com
Hi Chris,

Thanks for getting in touch. I've done exactly what you have suggested. Here is the URI (http://www.disciplinexgames.com/magellan/auth.php) as I asked in my question when a user fills in there username and password and hit authorise they go to https://active-api.magellangps.com. What I want is to redirect the user back to my domain (www.disciplinexgames.com) once the user has authorised and then save the access_token.

Chris Lukic

unread,
May 20, 2014, 9:07:11 AM5/20/14
to magellan-acti...@googlegroups.com
As far I know, I don't think the API can be used like that. You'll need some PHP code to get the username and password from your form, pass them in a GET request to Magellan (instead of a POST), retrieve and handle the response, and relay that information to the user. It's not OAuth2, it's just token based authentication.




------------------------------------------------
Chris Lukic  | Founder Smashrun







--
You received this message because you are subscribed to a topic in the Google Groups "Magellan Active Developers" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/magellan-active-developers/8gsTAC38eFU/unsubscribe.
To unsubscribe from this group and all its topics, send an email to magellan-active-dev...@googlegroups.com.

To post to this group, send email to magellan-acti...@googlegroups.com.
Visit this group at http://groups.google.com/group/magellan-active-developers.
For more options, visit https://groups.google.com/d/optout.

Pranav Bhatnagar

unread,
May 20, 2014, 10:41:53 AM5/20/14
to magellan-acti...@googlegroups.com
I tried to use AJAX for this but I'm getting same problem, which has been explained here http://www.codeproject.com/Questions/707290/Uncaught-SyntaxError-Unexpected-token-in-jquery-mo. Can you please give me some tips on how to get around it or how you have done it in smashrun ? I am looking for something same which you have done in Smashrun!

If I use JSON as in dataType then I get XMLHttpRequest cannot load because of security reasons as it is cross domain and if I use JSONP then I get

Uncaught SyntaxError: Unexpected token.


Any help will be great! Thanks in advance.
To unsubscribe from this group and all its topics, send an email to magellan-active-developers+unsub...@googlegroups.com.

Chris Lukic

unread,
May 20, 2014, 11:01:26 AM5/20/14
to magellan-acti...@googlegroups.com
You'll need to do this from PHP, because the browser does not allow XHR requests from a different origin domain. 

Steps:
  • Post request to your server
  • In PHP get username and password from form
  • Send Auth request from PHP to Magellan and return either XML or JSON
  • Check HTTP status code to see if Success or other error
  • If success parse XML or JSON and store auth token in database and use for repeat requests
  • If failure relay a message to the user "Invalid login"
Best luck,

Chris
To unsubscribe from this group and all its topics, send an email to magellan-active-dev...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages