Stuck in fetching Tokens from ebay

271 views Asked by At

Using C# MVC 5. This problem is occuring after hosting my app in IIS 8.

when my view page loads, loads with a anchor(Get Token) which redirects to the ebay sign in page with runame and session name(runame & sessionID was loaded in controller and passed via viewbag and bound with anchor tag click event).

In Controller:

apiContext.SignInUrl = "https://signin.sandbox.ebay.com/ws/eBayISAPI.dll?SignIn&RuName=" + apiContext.RuName + "&SessID=" + _sessionID;
ViewBag.sign = apiContext.SignInUrl;
ViewBag.SessionID = _sessionID;

In View :

$("#eBaySignIn").click(function () {

        var childUrl = "@ViewBag.sign";
        sessionID = "@ViewBag.SessionID";
        alert(sessionID);
        var timer = setInterval(checkChild, 500);
        var isClosed = false;
        function checkChild() {
            if (child.closed) {

                clearInterval(timer);
                var URL = '@Url.Action("AcceBayFinalReturn", "Settings")';
                $.ajax({
                    url: URL,
                    type: 'POST',
                    data: JSON.stringify({ sessionIDs: sessionID }),
                    dataType: 'json',
                    contentType: 'application/json',
                    success: function (data) {
                        alert('Succ');
                    },
                    error: function (data) {
                        alert('Error.');
                    }
                });
            }
        }
    });

The Sign in page loads in a child window correctly.

After "I Agree" in eBay consent form (after sign in) the window closed.

In main window I catch the event of closing child window and send the sessionID from view to controller through ajax(Code given above). In controller I call the FetchToken with apicontext and valid sessionID.

try
        {
            FetchTokenCall ftc = new FetchTokenCall(apiContext);
            _token = ftc.FetchToken(_sessionID);
            return _token;
        }
        catch (Exception)
        {
            return null;
        }

But unfortunately FetchToken returns nothing. How to solve it?

0

There are 0 answers