When I try to run an Appscript I get error ..
[17-02-08 01:00:35:160 PST] Open the following URL and re-run the script: https://accounts.google.com/o/oauth2/auth?client_id=317559754348->0p1ti3fmjae175i06hn07jrbia6701q6.apps.googleusercontent.com&response_type=code&redirect_uri=https%3A%2F%2Fscript.google.com%2Fmacros%2Fd>%2F1pgAT7ZCwiKrHx_7Iys770hJNRqTYwn9zioe9Qjvmhzc9rfIxO04P8Uum%2Fusercallback&state=ADEpC8xV9BMj3kqytygKLnjEYT7PX918NJg0i1oSCAsUTRwXcOgdzDStZA3lzGDK98CJ6OOhlDnlYEyyji5rx6P8haao8oDop->PMQBZsMMjk2Jl_GtsPnsifFDt1XjqSXtCS2Wx6X3fdLDHTlBzfwqvqrinfkHhW1dVw0oNv6-MaqDhimE912Po&scope=https%3A%2F%2Fwww.googleapis.com%2Fauth>%2Fdevstorage.read_write&access_type=offline&approval_prompt=force&login_hint=imerrywe%40jaguarlandrover.com
Trouble is Client ID 317559754348-0p1ti3fmjae175i06hn07jrbia6701q6.apps.googleusercontent.com
no longer exists. Looks like it has accidentaly been deleted. I have tried created new Oauth2 credentials but my appscript wants to use the old one.
How do I get my appscripts to use new credentials. ?
Regards, Ian
// Global Project variables
var CLIENT_ID = 'xxxxxxxxxx-
leuap166eur7gi5ufr6kiau2nqefknci.apps.googleusercontent.com';
var CLIENT_SECRET = 'xxxxxxxxxx';
// OAuth2.0 Access token
var token;
function oAuth() {
// Check we have access to the service
Logger.log(Session.getActiveUser().getEmail());
Logger.log( Session.getEffectiveUser().getEmail());
var service = getService();
Logger.log('Access '+service.hasAccess());
var authInfo = ScriptApp.getAuthorizationInfo(ScriptApp.AuthMode.FULL);
Logger.log(authInfo.getAuthorizationStatus());
if (!service.hasAccess()) {
var authorizationUrl = service.getAuthorizationUrl();
Logger.log('Open the following URL and re-run the script: %s',
authorizationUrl);
return;
}
}
function getService() {
// Create a new service with the given name. The name will be used when
// persisting the authorized token, so ensure it is unique within the
// scope of the property store.
return OAuth2.createService('xxxxxxxxxx')
// Set the endpoint URLs, which are the same for all Google services.
.setAuthorizationBaseUrl('https://accounts.google.com/o/oauth2/auth')
.setTokenUrl('https://accounts.google.com/o/oauth2/token')
// Set the client ID and secret, from the Google Developers Console.
.setClientId(CLIENT_ID)
.setClientSecret(CLIENT_SECRET)
// Set the name of the callback function in the script referenced
// above that should be invoked to complete the OAuth flow.
.setCallbackFunction('authCallback')
// Set the property store where authorized tokens should be persisted.
.setPropertyStore(PropertiesService.getUserProperties())
// Set the scopes to request (space-separated for Google services).
// this is admin access for the sqlservice and access to the cloud- platform:
.setScope('https://www.googleapis.com/auth/sqlservice.admin
https://www.googleapis.com/auth/cloud-platform')
// Below are Google-specific OAuth2 parameters.
// Sets the login hint, which will prevent the account chooser screen
// from being shown to users logged in with multiple accounts.
.setParam('login_hint', Session.getActiveUser().getEmail())
// Requests offline access.
.setParam('access_type', 'offline')
// Forces the approval prompt every time. This is useful for testing,
// but not desirable in a production application.
.setParam('approval_prompt', 'force');
}
- That’s an error.
Error: redirect_uri_mismatch
The redirect URI in the request, does not match the ones authorized for the OAuth >client. Visit >1 to update the authorized redirect URIs.

getService(). Also is the client ID really broken over two lines in your code? It won't work as you have it in your example. - Spencer Easton