want raw http requests to access my gmail contacts using curl

1,384 views
Skip to first unread message

ABDUL MOIZ

unread,
Jun 16, 2011, 10:04:14 AM6/16/11
to google-co...@googlegroups.com
Hi
       I am new to google contacts api.
   I have read the docs but could not get how to use oauth authentication and access my gmail contacts.Can anyone please help me out by giving me working http requests(oauth authentication process and get contacts list) using curl especially i am confused what to give values for  oauth_signature,oauth_nonce etc.,

This is what I have tried using curl

curl https://www.google.com/accounts/OAuthGetRequestToken?oauth_consumer_key=google.com&oauth_nonce=4572616e48616d6d65724c61686176&oauth_signature_method=RSA-SHA1&oauth_signature=wOJIO9A2W5mFwDgiDvZbTSMK%2FPY%3D&oauth_timestamp=1272197025&scope=https://www.google.com/m8/feeds/&oauth_callback=''&oauth_version=1.0&xoauth_displayname=moiz

Thanks in Advance

Alain Vongsouvanh

unread,
Jun 17, 2011, 12:01:25 PM6/17/11
to google-co...@googlegroups.com
Hello Abdul,

If using curl, I would suggest using OAuth 2.0 as it is much simplier to implement. You will need to log into your API Console in order to retrieve the needed client_id and client_secret.

After that, you will be able to call the Contacts API by specifying this authorization header:

Authorization: OAuth <YOUR_ACCESS_TOKEN>

Best,
Alain

--
You received this message because you are subscribed to the Google
Groups "Google Contacts, Shared Contacts and User Profiles APIs" group.
To post to this group, send email to
google-co...@googlegroups.com
To unsubscribe from this group, send email to
google-contacts...@googlegroups.com
For more options, visit this group at
http://code.google.com/apis/contacts/community/forum.html



--
Alain Vongsouvanh



ABDUL MOIZ

unread,
Jun 20, 2011, 1:59:28 AM6/20/11
to Google Contacts, Shared Contacts and User Profiles APIs

hi Alain Vongsouvanh,

Thanks for your reply.
I tried with the advice given by you .i.e i have requested API access
and I have got the client id and redirect uris
I have used oauth 2 API as shown below but still i could not get the
access token from the google server.

This is my curl command line:

curl https://accounts.google.com/o/oauth2/auth?client_id=586812405065.apps.googleusercontent.com&redirect_uri=urn:ietf:wg:oauth:2.0:oob
http://localhost&scope=https://www.google.com/m8/feeds/&response_type=token



Response I am getting is as shown below:

[1] 3951
[2] 3952
[3] 3953
bash: http://localhost: No such file or directory
<HTML>
<HEAD>
<TITLE>invalid_request: Required parameter is missing: response_type</
TITLE>
</HEAD>
<BODY BGCOLOR="#FFFFFF" TEXT="#000000">
<H1>invalid_request: Required parameter is missing: response_type</H1>
<H2>Error 400</H2>
</BODY>
</HTML>
^C
[1] Done curl
https://accounts.google.com/o/oauth2/auth?client_id=586812405065.apps.googleusercontent.com
[2]- Exit 127 redirect_uri=urn:ietf:wg:oauth:2.0:oob
http://localhost
[3]+ Done scope=https://www.google.com/m8/feeds/




Can you please tell me how can i get the access token

Regards
Abdul Moiz

On Jun 17, 9:01 pm, Alain Vongsouvanh <ala...@google.com> wrote:
> Hello Abdul,
>
> If using curl, I would suggest using OAuth
> 2.0<http://code.google.com/apis/accounts/docs/OAuth2.html>as it is
> much simplier to implement. You will need to log into your API
> Console <https://code.google.com/apis/console> in order to retrieve the
> needed client_id and client_secret.
>
> After that, you will be able to call the Contacts API by specifying this
> authorization header:
>
> Authorization: OAuth <YOUR_ACCESS_TOKEN>
>
> Best,
> Alain
>
>
>
> On Thu, Jun 16, 2011 at 7:04 AM, ABDUL MOIZ <abdulmoiz...@gmail.com> wrote:
> > Hi
> >        I am new to google contacts api.
> >    I have read the docs but could not get how to use oauth authentication
> > and access my gmail contacts.Can anyone please help me out by giving me
> > working http requests(oauth authentication process and get contacts list)
> > using curl especially i am confused what to give values for
> > oauth_signature,oauth_nonce etc.,
>
> > This is what I have tried using curl
>
> > curl
> >https://www.google.com/accounts/OAuthGetRequestToken?oauth_consumer_k...

Alain Vongsouvanh

unread,
Jun 20, 2011, 1:26:33 PM6/20/11
to google-co...@googlegroups.com
Hello Abdul,

Can you try this command line:
Also, this URL is to be visited by the user in order to grant access to your application by clicking on the "Allow" button. Also, the response_type has to be set to "code" in order to be used with the "urn:ietf:wg:oauth:2.0:oob" redirect URI since this is a native application flow. Once you get the access code back from the server, you can exchange it for an access and refresh token.

One more thing: please make sure to hide your client id and client secret when you copy and paste codes and/or command lines. You can ask for a new client id by going into the API Console.

Best,
Alain

ABDUL MOIZ

unread,
Jun 21, 2011, 2:23:30 AM6/21/11
to Google Contacts, Shared Contacts and User Profiles APIs

Hi Alain Vongsouvanh,

Thanks for your reply.
I have understood the process of getting access token for Oauth 2.0

Now I am developing QT based application using QOAuth library.
But QOAuth supports only OAuth 1.0.
So how can I get Consumerkey,Consumersecret,Oauth_signature for my
application using QAuth 1.0 and the QOAuth library apis is expecting
token as well as tokensecret from the server.
Can you please advice me in this regard

I am using the following urls in my application:

http://www.google.com/accounts/OAuthGetRequestToken
http://www.google.com/accounts/OAuthGetAccessToken

Thanks a lot for your support.

Regards
Abdul Moiz


On Jun 20, 10:26 pm, Alain Vongsouvanh <ala...@google.com> wrote:
> Hello Abdul,
>
> Can you try this command line:
>   curlhttps://accounts.google.com/o/oauth2/auth?client_id=586812405065.apps...
>
> Also, this URL is to be visited by the user in order to grant access to your
> application by clicking on the "Allow" button. Also, the response_type has
> to be set to "code" in order to be used with the "urn:ietf:wg:oauth:2.0:oob"
> redirect URI since this is a native application flow. Once you get the
> access code back from the server, you can exchange it for an access and
> refresh token.
>
> One more thing: please make sure to hide your client id and client secret
> when you copy and paste codes and/or command lines. You can ask for a new
> client id by going into the API Console.
>
> Best,
> Alain
>
>
>
> On Sun, Jun 19, 2011 at 10:59 PM, ABDUL MOIZ <abdulmoiz...@gmail.com> wrote:
>
> > hi Alain Vongsouvanh,
>
> >  Thanks for your reply.
> > I tried with the advice given by you .i.e i have requested API access
> > and I have got the client id and redirect uris
> > I have used oauth 2 API as shown below but still i could not get the
> > access token from the google server.
>
> > This is my curl command line:
>
> > curl
> >https://accounts.google.com/o/oauth2/auth?client_id=586812405065.apps...
> >http://localhost&scope=
> >https://www.google.com/m8/feeds/&response_type=token
>
> > Response I am getting is as shown below:
>
> > [1] 3951
> > [2] 3952
> > [3] 3953
> > bash:http://localhost:No such file or directory
> > <HTML>
> > <HEAD>
> > <TITLE>invalid_request: Required parameter is missing: response_type</
> > TITLE>
> > </HEAD>
> > <BODY BGCOLOR="#FFFFFF" TEXT="#000000">
> > <H1>invalid_request: Required parameter is missing: response_type</H1>
> > <H2>Error 400</H2>
> > </BODY>
> > </HTML>
> > ^C
> > [1]   Done                    curl
>
> >https://accounts.google.com/o/oauth2/auth?client_id=586812405065.apps...

Alain Vongsouvanh

unread,
Jun 21, 2011, 11:55:25 AM6/21/11
to google-co...@googlegroups.com
Hello Abdul,

An other developer has implemented a C++ client for the Google Tasks API using Qt and OAuth (though he used SimpleOAuth):
It might be interesting for you to check out his code and look into how he did the OAuth dance. Please make sure to change the scopes from the Tasks API scopes to the Contacts API scopes.

Best,
Alain
Alain Vongsouvanh | Developer Programs Engineer | ala...@google.com | +1 650 479-6719


ABDUL MOIZ

unread,
Jun 22, 2011, 3:24:08 PM6/22/11
to Google Contacts, Shared Contacts and User Profiles APIs
Hi Alain Vongsouvanh ,
Thanks for your reply.

I have gone through the QT code in the link you have given.
The developer has used SimpleOAuth library.
But SimpleOAuth library like QOAuth library supports only OAuth 1.0.
authentication in which the application uses "Consumerkey" and
"Consumersecret".

In the earlier post responses , you discussed about OAuth 2.0
authentication which gives "Client id" and "Client Secret"

Now Can you please tell me how to get "Consumerkey" and
"Consumersecret" for OAuth 1.0 authentication.
And how to get an application signed by google(and get signature key)
if it is installed application(no url).

Thanks once again for your support.

Regards
ABDUL MOIZ


On Jun 21, 8:55 pm, Alain Vongsouvanh <ala...@google.com> wrote:
> Hello Abdul,
>
> > > > bash:http://localhost:Nosuch file or directory
> 479-6719- Hide quoted text -
>
> - Show quoted text -

Alain Vongsouvanh

unread,
Jun 23, 2011, 12:34:12 PM6/23/11
to google-co...@googlegroups.com
Hello Abdul,

For installed application, you should use "anonymous" for both ConsumerKey and ConsumerSecret.
Also, please make sure to specify the "xoauth_displayname" query parameter when requesting access as it will let the server display your application name on the authorization page instead of "Anonymous".

Best,
Alain
Reply all
Reply to author
Forward
0 new messages