客户端ID不再存在

时间:2017-02-08 09:07:47

标签: google-apps-script google-cloud-platform

当我尝试运行Appscript时,我收到错误..

  

[17-02-08 01:00:35:160 PST]打开以下URL并重新运行脚本:https://accounts.google.com/o/oauth2/auth?client_id=317559754348-> 0p1ti3fmjae175i06hn07jrbia6701q6.apps.googleusercontent.com&安培; RESPONSE_TYPE =代码&安培; REDIRECT_URI = HTTPS%3A%2F%2Fscript.google.com%2Fmacros%2FD>%2F1pgAT7ZCwiKrHx_7Iys770hJNRqTYwn9zioe9Qjvmhzc9rfIxO04P8Uum%2Fusercallback&安培;状态= ADEpC8xV9BMj3kqytygKLnjEYT7PX918NJg0i1oSCAsUTRwXcOgdzDStZA3lzGDK98CJ6OOhlDnlYEyyji5rx6P8haao8oDop-> PMQBZsMMjk2Jl_GtsPnsifFDt1XjqSXtCS2Wx6X3fdLDHTlBzfwqvqrinfkHhW1dVw0oNv6-MaqDhimE912Po&安培;范围= HTTPS%3A%2F%2Fwww.googleapis.com%2Fauth>%2Fdevstorage。 READ_WRITE&安培; ACCESS_TYPE =离线&安培; approval_prompt =力&安培; login_hint = imerrywe%40jaguarlandrover.com

麻烦是客户ID 317559754348-0p1ti3fmjae175i06hn07jrbia6701q6.apps.googleusercontent.com

不再存在。看起来它被意外删除了。 我已尝试创建新的Oauth2凭据,但我的appscript想要使用旧的。

如何让我的appscripts使用新凭据。 ?

此致 伊恩

// 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');
}
  
      
  1. 这是一个错误。
  2.         

    错误:redirect_uri_mismatch

         

    请求中的重定向URI与授权给OAuth>客户端的URI不匹配。访问> 1以更新授权的重定向URI。

1 个答案:

答案 0 :(得分:0)

只是为了解决

  
      
  1. 这是一个错误。错误:redirect_uri_mismatch
  2.   

转到新的clientID,在它下面你可能需要添加“oauth2callback”重定向uri,如:

http://www.mywebsite.com/oauth2callback

enter image description here