Context --
- I am building a web application that uses the Google Cal and Google+ API.
- I will need to obtain a refresh token, since once a user authenticates with the site/app, some of the calls happen behind the scenes after they have logged in (and many of them happen after 1 hour, of which the initial access_token is valid for)
As I understand it, here is the flow I must follow:
- Register a Web Application API through Google console - done.
- Prompt the user to authenticate with my application, done through a call using the following config vars:
var config = {
'client_id': MY_CLIENT_ID',
'scope': 'https://www.googleapis.com/auth/calendar https://www.googleapis.com/auth/userinfo.email',
'response_type': 'code',
'access_type': 'offline'
};
- Then, using the Google object returned through the auth() call above, make another call to get the access_token and refresh_token.
https://developers.google.com/accounts/docs/OAuth2WebServer#refresh
POST /o/oauth2/token HTTP/1.1
Host: accounts.google.com
Content-Type: application/x-www-form-urlencoded
code=CODE_RETURNED
client_id=CLIENT_ID_RETURNED
client_secret=API_CLIENT_SECRET
redirect_uri=API_REDIRECT_API
grant_type=authorization_code
Yet, when I try to run this call I always get some type of error. Right now I am stuck getting the following:
{
error: "redirect_uri_mismatch"
}
I have the following listed as my redirect uri both on the Google API settings page, and in code:
http://localhost/
Any advice from someone that has worked with this flow before? Do I need to set up something differently for obtaining a refresh token?