我不确定将什么用作我的重定向URI。 Bitbucket有一个“回调URL”的空间,我假设它是输入的地方。其他人有这个问题/知道如何在这种情况下使用重定向URI?我正在下面设置我的服务对象。
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 :(得分:0)
当您收到错误403(或等效文件)时,您会看到“阅读更多”链接。单击它并复制粘贴它给出的预期链接。 现在,使用此链接在重定向uri中生成新凭据。
这个流程对我有用。希望它也适合你。