Extract BearerToken from LinqToTwitter IAuthorizer - twitter

Hopefully a simple answer to what I think is a simple question.
Is it possible to Extract the BearerToken from the IAuthorizer once I am authenticated? After using LinqToTwitter to authorize, I want to make my own API calls and I need the BearerToken to do so.
Thank you for your time in advance!

I'm assuming you're talking about ApplicationOnlyAuthorizer. The demos assign to IAuthorizer, so you need to convert to ApplicationOnlyAuthorizer to expose the BearerToken, like this:
await auth.AuthorizeAsync();
string bearerToken = (auth as ApplicationOnlyAuthorizer).BearerToken;

Related

Siesta Service configureTransformer for URL decode models based upon parameters

I have an endpoint which supports post requests. The URL is the same for all requests but the parameters will be different for each request. It is basically a free-form query service when the client can formulate the query and fields that will be returned in the response. I would like to be able to define methods on the service which will represent specific queries and a model for each query. But I am uncertain as to how I would go about configuring the transformer for each "query based" endpoint.
Is there a way to accomplish this or is it best to simply work with a json dictionary?
Thanks...
I think that I found the solution to my problem and it was rather simple. It was just a matter of building the resource and supplying it to configureTransformer.
func getUserIds() -> Request {
let res = resource(endPoint)
.withParam("query", "SELECT id FROM users where status='Active'")
configureTransformer(res) {
try self.jsonDecoder.decode(UserIdResponse.self, from: $0.content)
}
return res.request(.post)
}

How to get all the recent session for a user

I'm using the spring-session project and I find it quite awesome. My requirement is to show the customer a list of his latest logins (IP address, date/time of his latest logins). I'm looking at the SessionRepository but I can't seem to find such a method. Is it possible to introduce such a method to return a org.springframework.data.domain.Page of latest sessions for a given customer? If not could anyone suggest how to tackle this problem?
We want to keep SessionRepository as simple as possible, so it will not be introduced into that API. Instead, we will likely create an extension to the interface when resolving gh-7 is resolved.
In the meantime, you can extend the existing implementation to provide additional methods that map the additional necessary information.
for org.springframework.web.context.request.RequestContextHolder
example usage:
public static HttpSession session() {
ServletRequestAttributes attr = (ServletRequestAttributes) RequestContextHolder.currentRequestAttributes();
return attr.getRequest().getSession(true); // true == allow create
}

How to set Parameters for Titanium.Yahoo.YQL?

I cant find anyway to put parameters into YQL to fetch private data like contacts lists etc.I dont find it documented anywhere..
I know we can fetch public data without parameters but i am asking about private data which needs parameters like oauth_token and oauth_signature ?
Made my own alternative.It fetches Yahoo,MSN,Google Contacts for now.
OAuth_social

trigger io add default authorization header

Just wanted to understand what is the best way to add an Authorization header for all ajax requests using trigger io. Currently, I'm manually adding the header on each request. Would be great to know if such a feature is available or undocumented, and if not then what is the best way to do this. Something similar to AFNetworking which allows you to add persistent headers.
There isn't currently a way to set a default, you could write yourself a simple helper function though something like:
var username = "myuser";
var password = "skldjghslg";
function myAjax(options) {
options.username = username;
options.password = password;
forge.request.ajax(options);
}
Then whenever you would normally use forge.request.ajax just use myAjax.

Request variable in dotcms

Please find my requirement that needs to be done in dotcms-
1) I need to create a Map object for each request.
2) Across different widgets or containers i should be able to add data or get data from the Map object.
Can you please provide me a solution or idea to fulfill the requirement.
Thanks in advance
You can use the standard HTTPServletRequest methods, even from velocity:
$request.setAttribute("foo", "bar")
$request.getAttribute("foo") would print "bar"
$request.getParameter("foo") would get a GET or POST parameter "foo" and
#set($map = ${request.getParameterMap()}) would get the whole map.

Resources