verify credentials in flash

6 views
Skip to first unread message

cesare76

unread,
Mar 5, 2008, 11:13:17 AM3/5/08
to Twitter Development Talk
Hi guys,

I feel a bit stupid...but I can't port to Flex/Flash this simple
action:

curl -u username:password http://twitter.com/account/verify_credentials.json

to verify credentials. Can anybody help?

-c.

Marco Kaiser

unread,
Mar 5, 2008, 11:23:27 AM3/5/08
to twitter-deve...@googlegroups.com
Hi,

setting URL and authorization works like this:

var urlReq:URLRequest = new URLRequest();
urlReq.url = 'http://twitter.com/accounts/verify_credentials.json';

var auth:String = Base64.encode(username+':'+password);
urlReq.requestHeaders = new Array( new URLRequestHeader("Authorization","Basic "+auth));

-Marco

cesare76

unread,
Mar 5, 2008, 4:48:51 PM3/5/08
to Twitter Development Talk

On Mar 5, 5:23 pm, "Marco Kaiser" <kaiser.ma...@gmail.com> wrote:
> Hi,
>
> setting URL and authorization works like this:
>
> var urlReq:URLRequest = new URLRequest();
> urlReq.url = 'http://twitter.com/accounts/verify_credentials.json';
>
> var auth:String = Base64.encode(username+':'+password);
> urlReq.requestHeaders = new Array( new
> URLRequestHeader("Authorization","Basic "+auth));

Pretty similar to the one in the as library provide by twitter.

Tried that ...didn't work. At least not this afternoon.

Thanks anyway,

-c.

> -Marco

Marco Kaiser

unread,
Mar 5, 2008, 4:58:27 PM3/5/08
to twitter-deve...@googlegroups.com
Oh, you only tried today? Hmm, there seem to be quite a few people experiencing authorization problems with Twitter today. Maybe you are affected, too. Sorry.

thilo

unread,
Mar 5, 2008, 5:06:38 PM3/5/08
to Twitter Development Talk
Marco's code works in a desktop app. However, in a browser app you
cannot set http headers using flex.

@twibble

cesare76

unread,
Mar 5, 2008, 6:20:26 PM3/5/08
to Twitter Development Talk
> Marco's code works in a desktop app. However, in a browser app you
> cannot set http headers using flex.

I am in an AIR application:

I added a Urloader like this:

var loader:URLLoader = new URLLoader();
loader.addEventListener(Event.COMPLETE, callback);
loader.load(urlReq);

but I get a "that page does not exist" html message.

-c.

cesare76

unread,
Mar 5, 2008, 6:53:21 PM3/5/08
to Twitter Development Talk
> Oh, you only tried today? Hmm, there seem to be quite a few people
> experiencing authorization problems with Twitter today. Maybe you are
> affected, too. Sorry.

I am not ... I mean via curl it works. That makes me suspect it is a
matter of the flash client, not of the Twitter server.

-c.

bodyvisual

unread,
Mar 5, 2008, 6:59:35 PM3/5/08
to Twitter Development Talk
make sure you're setting urlReq.method = URLRequestMethod.POST

Marco Kaiser

unread,
Mar 5, 2008, 7:15:54 PM3/5/08
to twitter-deve...@googlegroups.com
POST for accessing verify_credentials? doesn't make much sense.

Getting a "Page does not exist" usually means you have a typo in your URL... wrong credentials would return no HTML.

cesare76

unread,
Mar 6, 2008, 6:36:09 AM3/6/08
to Twitter Development Talk
> Getting a "Page does not exist" usually means you have a typo in your URL...
> wrong credentials would return no HTML.

Damn!
The url was wrond.
"accounts" instead of "account" ...
Now it works ... though ... if the password is wrong,
air prompts a popup to enter uname and pwd ...
bu that's another issue...

Thanks to anybody,

-c.

Marco Kaiser

unread,
Mar 6, 2008, 7:12:06 AM3/6/08
to twitter-deve...@googlegroups.com
Setting

urlReq.authenticate = false;

will allow avoid the prompt and you can handle failed authentication yourself.

cesare76

unread,
Mar 6, 2008, 2:18:59 PM3/6/08
to Twitter Development Talk
> Setting
>
> urlReq.authenticate = false;
>
> will allow avoid the prompt and you can handle failed authentication
> yourself.

Thanks!

-c.

TarGz

unread,
Mar 24, 2008, 10:15:52 AM3/24/08
to Twitter Development Talk
Thanks for all this informations.

I'm trying to avoid the prompt and you can handle failed
authentication in my Flash application.
Have try "urlReq.authenticate = false;" but there is no "authenticate"
property in URLRequest class.

@cesare76 does it work for you ?

Marco Kaiser

unread,
Mar 24, 2008, 10:18:11 AM3/24/08
to twitter-deve...@googlegroups.com
URLRequest.authenticate is only available in AIR, not in regular Flash/Flex applications running in the browser :-/

TarGz

unread,
Mar 24, 2008, 10:19:50 AM3/24/08
to Twitter Development Talk
ok sorry for the last post, I finaly find the solution :


private function twitterRequest (URL : String):URLRequest{
var r:URLRequest = new URLRequest (URL);
var login64 : String = TwitterBase64.encode(_username + ":" +
_password);
var rArray : Array = new Array (new URLRequestHeader
("Authorization", "Basic " + login64));
var variables : URLVariables = new URLVariables ();
variables.authenticate = false;
r.data = variables;
r.requestHeaders = rArray;
r.method = URLRequestMethod.POST;
return r;
}


On Mar 6, 8:18 pm, cesare76 <cesareroc...@gmail.com> wrote:
Reply all
Reply to author
Forward
0 new messages