title: ApiGee OAUTH Authorization
body: <p>I'm new in apigee. I need to make a callout in my proxy to fetch data from google fusion tables. FT Service require secure call using oath 2.0. 
  I'm already made this workflow using custom proxy (without any OAUTH policy, and store token, refresh token and expiry in Key Value Map)</p>
  
  <p>also I made js to calculate expiration time and condition callout to refresh token. 
  I understand that this is not correct way but I still can't get a clue how to make this call using building Oauth policy. :(
  It's clear for me oauth process from google side but cant understand where i have store value and how to configure oauth as native way ... </p>
  
  <p>I successfully deploy oauth-authcode example from github and get it work but when i change Default Target Endpoint URL on <a href="https://accounts.google.com/o/oauth2/auth" rel="nofollow">https://accounts.google.com/o/oauth2/auth</a> and substitute my client_id i get error "Invalid client id : XXXXX.apps.googleusercontent.com. ClientId is Invalid".</p>
  
  <p>Well as I understand the first issue is get Authorization code 
  I have to make a call to google oauth like: </p>
  
  <pre><code>https://accounts.google.com/o/oauth2/auth
  ?response_type=code
  &amp;redirect_uri={URL that obtain access code}
  &amp;client_id=XXXXX.apps.googleusercontent.com
  &amp;scope=https://www.googleapis.com/auth/fusiontables 
  &amp;access_type=offline
  &amp;approval_prompt=force
  &amp;login_hint=MYEMAIL@gmail.com
  &amp;state=ANYSTATE
  </code></pre>
  
  <p>then google redirect authorization code to redirect_uri as </p>
  
  <pre><code>{redirect_uri}?code=ACCESSCODE&amp;state=ANYSTATE 
  </code></pre>
  
  <p>well i make a proxy /oauth20 as a bakckend and point it as redirect_uri. </p>
  
  <p>How to configure oauth policy on this end to store this code ? </p>
  
  <p>I create product Fusion and add API Proxy '/oauth20' as Resources 
  Also I created Developer App Fusion.</p>
  
  <p>What url i have to populate as Callback URL in Developer App? </p>
  
  <p>Which url I have to use as redirect url for oauth policy and how can I store client id and client secret and scope that I use for google? 
  I can't edit Consumer Key and Consumer Secret in Developer app </p>
  
  <p>Well my api proxy obtain Authorization code.</p>
  
  <p>How to change this code to access token?</p>
  
  <p>In my app i make POST : </p>
  
  <pre><code>https://accounts.google.com/o/oauth2/token 
  code={code} 
  client_id={ClientID} 
  client_secret={ClientSecret} 
  redirect_uri=https://vatsenko-test.apigee.net/v1/oauth20/oauth/authorize
  grant_type=authorization_code 
  </code></pre>
  
  <p>and then extract token </p>
  
  <pre><code>$.access_token 
  $.refresh_token 
  $.expires_in
  </code></pre>
  
  <p>is any way to manually configure oauth flow to get token ?
  (i mean hardcode client_id, client_secret,and code to fetch token and store it to apigee and then make only verifyaccesstoken policy in callout)</p>