Retrieving Temporary Access Token using jQuery OAUTH
===

I am attempting to make an API OAUTH2 call to Shopify to authenticate. When I go to my application, the first screen comes up. I press Install, and then it redirects me back to where I started. The problem is that when I get redirected, I cannnot seem to catch it in my jQuery ajax function and therefore I am unable to get the temporary token I need to create my permanent token from OAUTH. The 2nd image shows what is happening after I press install. My code so far is posed below. None of the console.log() functions are being called after I run the ajax call. 

My application URL for my app is set to 

    http://localhost 

and my application is running from 

    http://localhost/shippingcalculator.

I tested the calls in an external REST client program, and I managed to successfully get my access token, so it is not a problem with my credentials.

![Initial install screen][1]

![200OK and then the 302 Redirect][2]

![Runs fine in a REST client tester][3]


    <!DOCTYPE html>
<head>
	 <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
	 <script src="js/jsoauth.js"></script>
	 <script src="js/functions.js"></script>

	 <script type="text/javascript">

	 	function getParameterByName(name)
		{
		  name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
		  var regexS = "[\\?&]" + name + "=([^&#]*)";
		  var regex = new RegExp(regexS);
		  console.log(window.location.search);
		  var results = regex.exec(window.location.search);
		  if(results == null)
		    return "";
		  else
		    return decodeURIComponent(results[1].replace(/\+/g, " "));
		}

		function getTemporaryToken(token)
		{
			jso_configure({
				"shopify": {
					client_id: "67d7af798dd0a42e731af51ffa20dd7a", //This is your API Key for your App
					//redirect_uri: "", OPTIONAL - The URL that the merchant will be sent to once authentication is complete. Must be the same host as the Return URL specified in the application settings
					authorization: "https://emard-ratke3131.myshopify.com/admin/oauth/authorize", 
					//In your case the authorization would be https://SHOP_NAME.myshopify.com/admin/oauth/authorize
					scope: ["read_products"], //Set the scope to whatever you want to access from the API. Full list here: http://api.shopify.com/authentication.html
				}
			});

			$.oajax({
		        url: "https://emard-ratke3131.myshopify.com/admin/oauth/authorize",
		        jso_provider: "shopify",
		        jso_scopes: ["read_products"],
		        jso_allowia: true,
		        success: function(data) {
                                //Use data and exchange temporary token for permanent one
		        	if (jqXHR.status === 200){
		        		console.log("200");
		        	}
		        	if (jqXHR.status === 302){
		        		console.log("300");
		        	}
		            console.log("Response (shopify):");
		            console.log(data);
		        },
		        error: function(e) {
					console.log("Fail GET Request");
					console.log(e);
				},
				complete: function(xmlHttp) {
				    // xmlHttp is a XMLHttpRquest object
				    console.log(xmlHttp.status);
				}    
		    });

			console.log("Code: " + getParameterByName("code"));
		}
		}

		$(document).ready(function() {
			getTemporaryToken();
		});
	</script>
</head>
<body>
	Hello World!
</body>
</html>


  [1]: http://i.stack.imgur.com/2fyAD.png
  [2]: http://i.stack.imgur.com/auJ8c.png
  [3]: http://i.stack.imgur.com/5La0F.png