-1

When I try to use the token data it acts like it is out of scope or it leaked. I have tested this in firefox and cannot figure out what is happening. If you could help me understand why it fails to return the token please feel free to reply.

the code that retreives the token:

$(function() {
    var request = $.ajax({
        type: "GET",
        cache: false,
        data: {v: 1, r: 'requestToken', apikey: 'root', secret: 'root'},
        url: "/vdesktop/deskapi/",
        dataType: "json",

    });
    request.done(function(data) {
        if (data.statusCode == 1) {
                $token = data.response;
                $(document.body).data("token", data.response);
            } else{
                alert("Error: ("+data.statusCode+") "+data.response);
            }
    });
    request.fail(function(jqXHR, textStatus) {
        alert("Error: "+textStatus);
    });
    alert($(document.body).data("token"));
});

An example resultset from the server:
{"statusCode": 1, "response": "1fa8997a0cb5062144b25c1ff917a5f293bee88b62cd4f99aca26fda12515372" }

Edited by matthewl6970

3
Contributors
7
Replies
49
Views
4 Years
Discussion Span
Last Post by Troy III
0

When I try to use the token data it acts like it is out of scope or it leaked.

What do you mean by leaked? What kind of API are you using?

0

The token is empty/not returning a value once it gets to the alert on line 21 but it has a value in the ajax call. The API is a custom API I am developing for a new service I am putting together. The API is based off of OAuth 2. if you are refering to the js library I am using it is jquery.

Edited by matthewl6970: clearified some things.

0

The API is a custom API I am developing for a new service I am putting together.

You are pretty much on your own with this.

I thought it might be related to Facebook, Twitter, or any other OAuth API or Web applciation. If you are creating something on your own it's hard to anyone to help you because most likely has nothing to do with what I mention above (Facebook, Twitter, or any other OAuth API).

Edited by LastMitch

0

Ah ok. I did give an example json result in my first post so you guys have something to work with. I was hoping if someone can see a glaring mistake that has resulted in the token not being passed beyond the ajax call. Anyways thanks for your time LastMitch.

0

I don't understand the meaning of the word "token" in your usage. So I'm not sure I understand the problem you are facing. And you are using that "$" thing, which points that - the best pro:help you could get with this, lies at its lib., official web address.

-1

The token stands for security token used in OAuth which is actually data.response in the json result.

LOL! I didn't know that jquery had a forum. I'll try there.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.