Gmail Calendar Documents Reader Web more »
Recently Visited Groups | Help | Sign in
Google Groups Home
How to request an oauth token?
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
  13 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
 
zealalot  
View profile  
 More options Mar 20, 5:08 am
From: zealalot <zeala...@gmail.com>
Date: Fri, 20 Mar 2009 02:08:56 -0700 (PDT)
Local: Fri, Mar 20 2009 5:08 am
Subject: How to request an oauth token?
Having trouble requesting an OAuth token.  Can anyone here help?
First off, I'm not sure what URL to send the POST request to.
Secondly, do I need to declare a method?  Any help greatly
appreciated..

-- code ---

import urllib.request, urllib.parse, time, string, random

class OAuthToken():
    """Simple object for requesting an OAuth token"""
    def __init__(self, consumer_key, secret_key):
        self.tokreq = {'method': 'authorize'} #no idea what to put for
method
        self.tokreq['oauth_consumer_key'] = consumer_key
        self.tokreq['oauth_signature_method'] = 'HMAC-SHA1'
        self.tokreq['oauth_signature'] = secret_key
        self.tokreq['oauth_timestamp'] = str(int(time.time()))
        self.tokreq['oauth_nonce'] = random.choice
(string.ascii_letters) #Build random nonce
        for i in range(0,15):
            self.tokreq['oauth_nonce'] += random.choice
(string.ascii_letters)

    def get_token(self, url='http://api.jaiku.com/json/api/
request_token'): #is this the right url?
        """Requests an OAuth token from the specified URL"""
        fh = urllib.request.urlopen(url, urllib.parse.urlencode
(self.tokreq))
        print(fh.read())

mytoken = OAuthToken('2ff4540897c94f58ae77611eddf1e42c', 'secret')
mytoken.get_token()


    Reply to author    Forward  
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.
Kim Bach  
View profile  
 More options Mar 20, 6:08 am
From: Kim Bach <kim.b...@gmail.com>
Date: Fri, 20 Mar 2009 03:08:41 -0700 (PDT)
Local: Fri, Mar 20 2009 6:08 am
Subject: Re: How to request an oauth token?
I have a similar problem, but I'm using the oauth Python library
http://oauth.googlecode.com/svn/code/python/oauth/ from Google Code,
which frankly seems like overkill for generating HTTP parameters and
headers, but I suppose it might pay off, I also got inspiration from
the "gifts" demo project http://code.google.com/intl/da/apis/opensocial/articles/appengine-0.8...,
that uses orkut for authentication.

The result no matter what I try,  I get the dreaded HTTP Error 500 -
it's possible I'm doing something wrong, but error 500 doesn't exactly
give me a lot to work with.

My Jaiku handle is @kimbach

On 20 Mar., 10:08, zealalot <zeala...@gmail.com> wrote:


    Reply to author    Forward  
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.
zealalot  
View profile  
 More options Mar 20, 10:38 am
From: zealalot <zeala...@gmail.com>
Date: Fri, 20 Mar 2009 07:38:49 -0700 (PDT)
Local: Fri, Mar 20 2009 10:38 am
Subject: Re: How to request an oauth token?
Thanks for the reply Kim.

I was wondering, what URL do you send your POST request to?  I've
tried http://jaiku.com/api/request_token and http://api.jaiku.com/json.
I get the 'something broke' page on the first, and 'invalid method' on
the second.

Thanks,

zealalot@jaiku

On Mar 20, 6:08 am, Kim Bach <kim.b...@gmail.com> wrote:


    Reply to author    Forward  
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.
Kim Bach  
View profile  
 More options Mar 20, 10:51 am
From: Kim Bach <kim.b...@gmail.com>
Date: Fri, 20 Mar 2009 07:51:05 -0700 (PDT)
Local: Fri, Mar 20 2009 10:51 am
Subject: Re: How to request an oauth token?
I'm connecting to www.jaiku.com on port 80 (it will most likely
resolve to the same IP as jaiku.com), after that I try to access /api/
request_token which is an OAuth best-practice AFAIK

On 20 Mar., 15:38, zealalot <zeala...@gmail.com> wrote:


    Reply to author    Forward  
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.
zealalot  
View profile  
 More options Mar 23, 12:42 pm
From: zealalot <zeala...@gmail.com>
Date: Mon, 23 Mar 2009 09:42:43 -0700 (PDT)
Local: Mon, Mar 23 2009 12:42 pm
Subject: Re: How to request an oauth token?
Well, I finally managed to get a request_token!  Now if I could only
figure out how to authorize it, and get an access_token.  To finally
get the request token, I used 'GET' instead of 'POST' and
'www.jaiku.com' instead of 'jaiku.com'.  Here's my code:

-- CODE --
#!/usr/bin/python

import oauth, httplib, urllib

#Define Constants
KEY = 'Your key from the JAIKU API page' #Change Me
SECRET = 'Your secret key' #Change Me
SERVER = 'www.jaiku.com'
REQURL = '/api/request_token'

class MyOAuthClient(oauth.OAuthClient):

    def __init__(self, server, request_token_url):
        self.server = server
        self.request_token_url = request_token_url
        self.full_request_url = "http://" + self.server +
self.request_token_url
        self.connection = httplib.HTTPConnection(self.server)

    def fetch_request_token(self, oauth_request):
        self.connection.request('GET', self.request_token_url,
headers=oauth_request.to_header())
        response = self.connection.getresponse()
        return oauth.OAuthToken.from_string(response.read())

if __name__ == "__main__":
    #Initialize
    client = MyOAuthClient(SERVER, REQURL)
    consumer = oauth.OAuthConsumer(KEY, SECRET)
    sig_method = oauth.OAuthSignatureMethod_HMAC_SHA1()

    #Request Token
    oauth_request = oauth.OAuthRequest.from_consumer_and_token
(consumer, http_url=client.full_request_url)
    oauth_request.sign_request(sig_method, consumer, None)
    token = client.fetch_request_token(oauth_request)

    print "-Token: " + str(token) + " .."

-- CODE --

On Mar 20, 10:51 am, Kim Bach <kim.b...@gmail.com> wrote:


    Reply to author    Forward  
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.
Kim Bach  
View profile  
 More options Mar 24, 4:44 am
From: Kim Bach <kim.b...@gmail.com>
Date: Tue, 24 Mar 2009 01:44:25 -0700 (PDT)
Local: Tues, Mar 24 2009 4:44 am
Subject: Re: How to request an oauth token?
Thanks that helped me too, now I also get request tokens, and I was
also able to generate the authorize URL (in this format:
http://www.jaiku.com/api/authorize?oauth_token=REQUEST_TOKEN_KEY&perm...),
and Jaiku apparently accepted the autorization request, unfortunately
the autorized tokens didn't show up on the list of authorized tokens
(http://www.jaiku.com/api/tokens), and I suspect that that is the
reason the subsequent requests for access tokens fails. I'm trying to
look at the #JaikuEngine source for clues.

It also seems wrong to me that we're served some HTML and HTTP 200 in
case of an error, but I don't know the OAuth best pratice on error
handling.

On 23 Mar., 17:42, zealalot <zeala...@gmail.com> wrote:


    Reply to author    Forward  
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.
zealalot  
View profile  
 More options Mar 24, 9:41 pm
From: zealalot <zeala...@gmail.com>
Date: Tue, 24 Mar 2009 18:41:26 -0700 (PDT)
Local: Tues, Mar 24 2009 9:41 pm
Subject: Re: How to request an oauth token?
For me to get an authorized request, I actually ended up building
something like:

'http://jaiku.appspot.com/login?redirect_to=%2Fapi%2Fauthorize
%3Foauth_token%3D' + REQUEST_TOKEN_KEY + '%26perms%3Dwrite'

After that, the token actually showed up in my activated tokens list.

On Mar 24, 4:44 am, Kim Bach <kim.b...@gmail.com> wrote:


    Reply to author    Forward  
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.
Kim Bach  
View profile  
 More options Mar 25, 9:27 am
From: Kim Bach <kim.b...@gmail.com>
Date: Wed, 25 Mar 2009 06:27:32 -0700 (PDT)
Local: Wed, Mar 25 2009 9:27 am
Subject: Re: How to request an oauth token?
So far I've had no success getting anything show up in the list of
authorised API tokens (http://www.jaiku.com/api/tokens)

What is the name of your app, I might try using the same appname

On 25 Mar., 02:41, zealalot <zeala...@gmail.com> wrote:


    Reply to author    Forward  
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.
jade  
View profile  
 More options Mar 27, 5:51 am
From: jade <giada.fatare...@gmail.com>
Date: Fri, 27 Mar 2009 02:51:37 -0700 (PDT)
Local: Fri, Mar 27 2009 5:51 am
Subject: Re: How to request an oauth token?
Hi all,

I have the same problem, I can't get the
access token.
After a user authorizes a request token (he clicks
the button 'authorize' in /api/authorize page) he's not redirected
back to my website but he remains in the same page and I can't go on
to ask for an access token.
And also the autorized tokens don't show up on the list of authorized
tokens (http://www.jaiku.com/api/tokens)
I have added to the authorize url the oauth_callback parameter with a
url on my website to let me know that the user has completed
authorizing me and to get the authorized token but it doesn't work

Thanks for any help...

On 25 Mar, 14:27, Kim Bach <kim.b...@gmail.com> wrote:


    Reply to author    Forward  
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.
Kim Bach  
View profile  
 More options Mar 28, 2:08 am
From: Kim Bach <kim.b...@gmail.com>
Date: Fri, 27 Mar 2009 23:08:54 -0700 (PDT)
Local: Sat, Mar 28 2009 2:08 am
Subject: Re: How to request an oauth token?
Progress :-), @zealot will share his code soon:
http://zealalot.jaiku.com/presence/68b39823eb5e4b7d8a126a7af4f51bd9

On 27 Mar., 10:51, jade <giada.fatare...@gmail.com> wrote:


    Reply to author    Forward  
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.
Kim Bach  
View profile  
 More options Mar 30, 6:23 am
From: Kim Bach <kim.b...@gmail.com>
Date: Mon, 30 Mar 2009 03:23:38 -0700 (PDT)
Local: Mon, Mar 30 2009 6:23 am
Subject: Re: How to request an oauth token?
@zealalot has posted this code. I haven't tried it yet, but I suppose
that it'll work

http://code.google.com/p/zealots-pjs/downloads/list

On 28 Mar., 08:08, Kim Bach <kim.b...@gmail.com> wrote:


    Reply to author    Forward  
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.
jade  
View profile  
 More options Apr 3, 10:48 am
From: jade <giada.fatare...@gmail.com>
Date: Fri, 3 Apr 2009 07:48:01 -0700 (PDT)
Local: Fri, Apr 3 2009 10:48 am
Subject: Re: How to request an oauth token?
Does @zealalot code work? Have you tried it also with oauth_callback
parameter?

Thanks

On 30 Mar, 12:23, Kim Bach <kim.b...@gmail.com> wrote:


    Reply to author    Forward  
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.
jmiller  
View profile  
 More options Apr 4, 4:14 pm
From: jmiller <jeffmil...@jeffmiller.name>
Date: Sat, 4 Apr 2009 13:14:26 -0700 (PDT)
Local: Sat, Apr 4 2009 4:14 pm
Subject: Re: How to request an oauth token?
Zealots code was a good start.  Unfortunately oauth_callback in web
mode is broken.  I submitted a patch and it looks like it's been
picked up.  Hopefully it will be fixed soon.

http://code.google.com/p/jaikuengine/issues/detail?id=77

On Apr 3, 3:48 pm, jade <giada.fatare...@gmail.com> wrote:


    Reply to author    Forward  
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 »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google