+1

Adding dynamic header content to httpheader?

sstava 11 år siden opdateret 11 år siden 7
I have moved along fairly well with my Parse.com integration, but I have a need to pass the session token of the logged in parse.com user in the httpheader of my datasource request.

The httpheader parameter is X-Parse-Session-Token. The issue I have is that the value for the session token needs to be dynamically added to the httpheader after the user has logged in.

I have tried adding: X-Parse-Session-Token="[var:signin-SessionToken]" to the httpheader tag. My hope was that when I assigned the content to the postContent property that the httpheader would do variable replacements...I don't think it does :(

I am hoping that I am missing something obvious; any thoughts?
Steve,

You can use an assign like so, that appends your htttpheader request whenever you need to update it.

<assign property="httpheader:datasourceName.X-Parse-Session-Token" value="[YOUR VALUE]" />
Excellent! Thanks for the quick response!
I don't think I have things working correctly. When I try to retrieve the user on the parse.com side, it gives me a null object. I am assuming that the session token is not getting passed through, but I am not sure.

I have added the following "assign" ahead of each of my "assigns" for the source property of the datasource to parse.com that requires a user to have been authenticated.

I have "alerted" the value of the session token after login to make sure I have a token to assign, and I do.

I have tried to "alert" the value of [httpheader:parseSetQueueing.X-Parse-Session-Token] to see if the "assign" has worked, but I can't get that to work. I don't know if it is supposed to.

Also, I have tried adding X-Parse-Session-Token="" and I have tried not having it in the header initially and assuming it will get added/assigned when I use the assign tag. Neither of them made a difference.

One of my "assign" tags:

<assign property="httpheader:parseSetQueueing.X-Parse-Session-Token" value="[var:signin-SessionToken]" />


Any thoughts?

P.S. I am heading over to the Parse.com side to see if I can figure out how to display the http header info being passed in to their system
More info

I setup a specific test to find out where the breaking point is in the process of assigning the X-Parse-Session-Token.

1) logged in via a terminal and curl to Parse.com to get a session token.
2) took the returned session token and hard-coded it in the httpheader in my wire
3) called a REST api in parse.com, from my wire, and it worked
4) removed the value of the session token from the httpheader and put it in the assign tag, to set the header value, just before setting the source tag of the datasource
5) called a REST api in parse.com and it failed :(

Since it worked with a hard-coded session token in the httpheader tag itself, but not when I did the assign tag (as shown in my prior comments) with a hard-coded value of the session token...

I think I still need your help, please :)

Steve
Steve,

Might need to have a look at the code to get a better look, but before we do that...lets try one more thing.

Create a texttemple like so:

<texttemplate name="sessionTokenOut"><![CDATA[X-Parse-Session-Token="[preferences:sessionToken]"]]></texttemplate>

Then in an action do the following:


<assign property="preferences:sessionToken" value="[datasource:tokenAuth.1.token]" />
<assign property="httpheader:appToken.Authorization" value="[template:sessionTokenOut.content]" />
Thanks, but it didn't work. I am in the process of creating a simplified version of the scenario. I will share that with you.
OK...just to make sure it is available for everyone else


<assign property="httpheader:parseHeader.X-Parse-Session-Token" value="[var:signin-SessionToken]" />


All you have to do to make this work for your session tag with parse.com is to
1) Replace my value of "parseHeader" with the name of your wire httpheader tag
2) Replace my value of "var:signin-SessionToken" with the name of your wire variable containing the session token returned from the parse.com login call

All your subsequent calls to wire REST apis will have access to the user that is logged in which means you can reference "request.user" in your parse.com cloud code

Kundesupport af UserEcho