グーグルクラウドストレージにグーグルドキュメントを保存したい。私は管理者ユーザーであり、Googleクラウドストレージにアクセスできます。私はこのコードを使用しています:
function myFunction() {
var base="https://www.googleapis.com/auth/devstorage.full_control"
var fetchArgs=googleOAuth_('provisioning',base)
fetchArgs.payload=<content_data_that you want to put on GCS>
fetchArgs.method='PUT'
fetchArgs. contentType=<content_type>
fetchArgs.host="<bucket_name>.storage.googleapis.com"
var url='https://storage.googleapis.com/<bucket_name>/<file_name>'
var result=UrlFetchApp.fetch(url,fetchArgs)
}
function googleOAuth_(name,scope) {
var oAuthConfig = UrlFetchApp.addOAuthService(name);
oAuthConfig.setRequestTokenUrl("https://www.google.com/accounts/OAuthGetRequestToken?scope="+scope);
oAuthConfig.setAuthorizationUrl("https://www.google.com/accounts/OAuthAuthorizeToken");
oAuthConfig.setAccessTokenUrl("https://www.google.com/accounts/OAuthGetAccessToken");
oAuthConfig.setConsumerKey(consumerKey);
oAuthConfig.setConsumerSecret(consumerSecret);
return {oAuthServiceName:name, oAuthUseToken:"always"};
}
このコードを実行すると、503サーバーエラーが発生します。どんな提案も私に役立つでしょう。
この問題は解決されました。コードを修正して更新しました。