Account Options

  1. Sign in
The old Google Groups will be going away soon.
Switch to the new Google Groups.
Google Groups Home
« Groups Home
What's can i do with user token if my server is not hosing on GAE?
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  4 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Vincent Tsao  
View profile  
 More options Aug 18 2010, 3:12 am
From: Vincent Tsao <caojunvinc...@gmail.com>
Date: Wed, 18 Aug 2010 15:12:09 +0800
Local: Wed, Aug 18 2010 3:12 am
Subject: [Help] What's can i do with user token if my server is not hosing on GAE?

I found this snippet from Chrometophone-android  DeviceRegistrar.java

   // Register device with server
        DefaultHttpClient client = new DefaultHttpClient();
        String continueURL = BASE_URL;

        URI uri = new URI(AUTH_URL + "?continue=" +
                URLEncoder.encode(continueURL, "UTF-8") +
                "&auth=" + authToken);
        HttpGet method = new HttpGet(uri);
        // No redirect following - continue is not used
        final HttpParams params = new BasicHttpParams();
        HttpClientParams.setRedirecting(params, false);
        method.setParams(params);

        HttpResponse res = client.execute(method);
        Header[] headers = res.getHeaders("Set-Cookie");
        if (res.getStatusLine().getStatusCode() != 302 ||
                headers.length == 0) {
            return res;
        }
        String ascidCookie = null;
        for (Header header: headers) {
            if (header.getValue().indexOf("ACSID=") >=0) {
                // let's parse it
                String value = header.getValue();
                String[] pairs = value.split(";");
                ascidCookie = pairs[0];
            }
        }a

the snippet shows us before android app send Registration ID to 3rd party
server, we need fetch the current account cookie from Google Account server,
here is what i figure:

   1. get current account TOKEN  (AuthSub token) from AccountManager
   2. start a request to server, which hosting on GAE**, with this kind of
   URL:
   https://yourapp.appspot.com/_ah/login?continue=http://localhost/&auth=
   TOKEN
   3. fetch cookie from server, and use that authentication cookie in all
   subsequent requests

here is my problem, my server will not hosting on GAE, so i need implement
all the account auth stuff myself.  the android app also need to send a
request to get account cookie from my server, but how should i know if this
request is valid or not a fake request ? what's can i do with the email and
token, can i using this token to get the related account email?


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Tomas Malmsten  
View profile  
 More options Sep 8 2010, 3:27 am
From: Tomas Malmsten <c...@tomasmalmsten.com>
Date: Wed, 8 Sep 2010 00:27:53 -0700 (PDT)
Local: Wed, Sep 8 2010 3:27 am
Subject: Re: What's can i do with user token if my server is not hosing on GAE?
Hello Vincent,

This is a late replay and perhaps no longer needed.

I wrote the application server using Python and am so far hosting it
on my local machine. The Client Login token is fetched in a factory
class. The code is below:

class ClientLoginTokenFactory():
    _token = None

    def __init__(self):
        self.url = 'https://www.google.com/accounts/ClientLogin'
        self.account_type = 'HOSTED_OR_GOOGLE'
        self.email = 'gmail.registerd.to.use.c2...@gmail.com'
        self.password = 'passwordForAboveAccount'
        self.source = 'SOME_SOURCE_STRING'
        self.service = 'ac2dm'

    def get_token(self):
        if(self._token is None):
            values = {'accountType' : self.account_type,
                      'Email' : self.email,
                      'Passwd' : self.password,
                      'source' : self.source,
                      'service' : self.service}
            data = urllib.urlencode(values)
            request = urllib2.Request(self.url, data)
            response = urllib2.urlopen(request)
            responseAsString = response.read()
            responseAsList = responseAsString.split('\n')
            self._token = responseAsList[2].split('=')[1]
        return self._token

The get_token method will return the token you need to insert into the
request sent to the C2DM service hosted by Google. What is required is
that your server has internet access.

Hope this helps

Regards
Tomas Malmsten
http://www.tomasmalmsten.com/

On Aug 18, 9:12 am, Vincent Tsao <caojunvinc...@gmail.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Vincent Tsao  
View profile  
 More options Oct 10 2010, 10:58 pm
From: Vincent Tsao <caojunvinc...@gmail.com>
Date: Mon, 11 Oct 2010 10:58:06 +0800
Local: Sun, Oct 10 2010 10:58 pm
Subject: Re: What's can i do with user token if my server is not hosing on GAE?

Hi Tomas, thanks for your reply

y, my problem has been solved already.

my server is powered by ROR, and build my user system myself. so user's
email is necessary, however, bad guy can fake a sign-up request using  email
which may not belong to him. Fortunately, i can use token to check if the
email is valid via GData API

On Wed, Sep 8, 2010 at 3:27 PM, Tomas Malmsten <c...@tomasmalmsten.com>wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Costin Manolache  
View profile  
 More options Oct 11 2010, 12:29 am
From: Costin Manolache <cos...@google.com>
Date: Sun, 10 Oct 2010 21:29:58 -0700
Local: Mon, Oct 11 2010 12:29 am
Subject: Re: What's can i do with user token if my server is not hosing on GAE?

I should note that it's recommended to use ClientLogin outside of the hosted
app, so the
server only has access to the token. The token can only be used for sending
messages.

Also in the response you should check the headers for an updated token.

Costin

On Wed, Sep 8, 2010 at 12:27 AM, Tomas Malmsten <c...@tomasmalmsten.com>wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »