0

我不確定要將什麼用作我的重定向URI。 Bitbucket有一個「回調URL」的空間,我假設它是輸入的地方。任何人都有這個問題/知道如何在這種情況下使用重定向URI?我正在設置我的服務對象。使用OAuth2獲取無效的redirect_uri Google表格

function getBitbucketServiceOAuth2() 
{ 
// 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('bitbucket') 

    // Set the endpoint URLs, which are the same for all Google services. 
    .setAuthorizationBaseUrl('https://bitbucket.org/site/oauth2/authorize') 
    .setTokenUrl('https://bitbucket.org/site/oauth2/access_token') 

    // Set the client ID and secret, from the Google Developers Console. 
    .setClientId('WL6MQbGku7axd5kqun') 
    .setClientSecret('jTRmqm5ug9fEUMAxeCQRx95uQz8LCevW') 

    // 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). 
// .setScope('https://www.googleapis.com/auth/drive') 

    // 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'); 
} 

然後獲取下面的授權網址。

var authorizationUrl = service.getAuthorizationUrl(); 

var template = HtmlService.createTemplate(
    '<a href="<?= authorizationUrl ?>" target="_blank">Authorize</a>. ' + 
    'Reopen the sidebar when the authorization is complete.'); 
template.authorizationUrl = authorizationUrl; 
var page = template.evaluate(); 

SpreadsheetApp.getUi().showSidebar(page); 

任何幫助將是偉大的!

回答

0

當您收到錯誤403(或等效)時,您將看到「閱讀更多」鏈接。點擊它並複製粘貼它給出的預期鏈接。 現在,使用此鏈接在重定向uri中生成新的憑據。

這個流程適用於我。希望它也適用於你。

相關問題