开发者

Oauth query - using access token and secret

开发者 https://www.devze.com 2023-02-03 07:31 出处:网络
I am developing an application based on google Oauth. Now my all authentications are done. Even I have now the a开发者_如何学运维ccess token and secret. Now I dont know how to use this access token an

I am developing an application based on google Oauth. Now my all authentications are done. Even I have now the a开发者_如何学运维ccess token and secret. Now I dont know how to use this access token and secret. Please I really need Help on this. I have already done the hard work which is getting access token and secret. Only need to know how to use this token and secret to call an api.


To use the access key/secret you

  1. set inputparameters for the google client service
  2. create a token using the access key and secret, and the inputparameters
  3. set the token in the google client service

In Python, using the gdata library:

    self.gd_client.SetOAuthInputParameters(
        gdata.auth.OAuthSignatureMethod.HMAC_SHA1,
        self.consumer_key, consumer_secret=self.consumer_secret)
    oauth_input_params = gdata.auth.OAuthInputParams(
        gdata.auth.OAuthSignatureMethod.HMAC_SHA1,
        self.consumer_key, consumer_secret=self.consumer_secret)
    oauth_token = gdata.auth.OAuthToken(key=access_key,
                                        secret=access_secret,
                                        scopes=gdata.gauth.AUTH_SCOPES,
                                        oauth_input_params=oauth_input_params)
    self.gd_client.SetOAuthToken(oauth_token)

After that you can call the service methods to retrieve the data.

Nico

0

精彩评论

暂无评论...
验证码 换一张
取 消