我正在使用google api ruby 客户端将 webhook 添加到日历中,但我遇到了Google::Apis::ClientError: pushWebhookBadDomain.
我已经设置了一个 ngrok 实例并在网站管理员工具上验证了它,以便我可以将其作为允许的域添加到处理所有日历身份验证等的项目中。我找不到任何对该特定错误的引用,所以我'我想知道使用 ngrok 是否有什么奇怪的地方,以及是否有更好的方法可以在本地测试 webhook。
这是为了防止我做任何愚蠢的事情而进行的通话(为了清晰起见,进行了精简):
require 'google/apis/calendar_v3'
client = Google::Apis::CalendarV3::CalendarService.new
authorization = Signet::OAuth2::Client.new(
:authorization_uri =>
'https://accounts.google.com/o/oauth2/auth',
:token_credential_uri =>
'https://accounts.google.com/o/oauth2/token'
)
authorization.client_id = ENV['GOOGLE_CLIENT_ID']
authorization.client_secret = ENV['GOOGLE_CLIENT_SECRET']
authorization.grant_type = 'refresh_token'
authorization.refresh_token = refresh_token
authorization.fetch_access_token!
client.authorization = authorization
channel = Google::Apis::CalendarV3::Channel.new(address: success_callback_url, id: channel_id, type: "web_hook")
binding.pry
webhook = client.watch_event('primary', channel, single_events: true, time_min: Time.now.iso8601)
Run Code Online (Sandbox Code Playgroud) ruby-on-rails google-calendar-api google-api-client google-api-ruby-client
我正在尝试从本地服务器调用Purchases.Subscriptions: get,但收到一条错误消息Error: Login Required: 。
我已经创建了一个具有项目所有者角色的服务帐户,如此处所述。然后,我设置GOOGLE_APPLICATION_CREDENTIALS环境变量并使其指向此处提到的下载的 JSON 文件。
最后,我尝试根据网站文档示例运行一些用于服务器到服务器身份验证的示例代码,看看是否可以成功进行身份验证:
import { google } from 'googleapis'
async function main() {
try {
const auth = new google.auth.GoogleAuth({
scopes: ['https://www.googleapis.com/auth/androidpublisher']
})
const authClient = await auth.getClient()
const project = await auth.getProjectId()
const publisher = google.androidpublisher('v3')
const result = await publisher.purchases.subscriptions.get({
packageName: 'com.mywebsite.subdomain',
subscriptionId: 'com.mywebsite.subscription_name',
token: '...my purchase token...'
})
console.log(result)
} catch (error) {
console.error(error)
}
}
main()
Run Code Online (Sandbox Code Playgroud)
google-api google-api-client google-api-nodejs-client play-billing-library
创建凭据后,请转到 Cloud Console 中的凭据页面并点击下载 JSON file_download,下载 client_secret.json 文件。
凭证页面有超链接。但是当您转到该页面时,没有名为“下载 json 文件”的按钮。这是页面的屏幕截图:
我真的希望谷歌能够学会编写清晰的文档。
我还应该补充一点,该网站有以下神秘说明:
通过使用 key=API_KEY 参数传递该密钥,可以在您的应用程序中使用该密钥。
我不知道传递密钥是什么意思。如果作者能提供一个例子,那肯定会有所帮助。我有钥匙,这可能会解决我的问题,但我不知道该怎么办。
我希望使用 PHP 脚本和 Google Drive API(将设置为 cron 作业)将 MySQL 备份从网络服务器推送到 Google Drive。
我知道这是一个服务器到服务器的应用程序,因此需要 Google 服务帐户(我知道可以使用用户帐户并刷新访问令牌 - 但我认为这不是正确的用例因为我不希望有任何用户交互?)。
我已在 Cloud Console 中设置了 Google 服务帐号。使用我的常规帐户,我与服务帐户共享一个目录,并且我尝试使用以下脚本上传测试文件:
function getClient()
{
$client = new Google_Client();
if ($credentials_file = checkServiceAccountCredentialsFile())
{
// set the location manually
$client->setAuthConfig($credentials_file);
}
else
{
echo missingServiceAccountDetailsWarning();
return;
}
$client->setApplicationName('Backups');
$client->setScopes(Google_Service_Drive::DRIVE);
$guzzleClient = new \GuzzleHttp\Client(array( 'curl' => array( CURLOPT_SSL_VERIFYPEER => false, ), ));
$client->setHttpClient($guzzleClient);
return $client;
}
Run Code Online (Sandbox Code Playgroud)
$file_to_upload = 'test.txt';
if(file_exists($file_to_upload))
{
// Get the API client and construct the service …Run Code Online (Sandbox Code Playgroud) php google-api google-api-client google-drive-api google-api-php-client
nextSyncToken我在回复中没有看到。我按照文档(https://developers.google.com/calendar/api/guides/sync)并使用分页,但我在最后一页nextPageToken上看不到。nextSyncToken
使用的API:GET /calendars/primary/events?maxResults=10&singleEvents=true&pageToken=********
我不知道我是否错过了这里的任何东西。有人能帮我解决这个问题吗?
我正在尝试将google analytics api用于我的帐户.所以首先我允许使用脱机刷新令牌访问应用程序.当我尝试刷新令牌时购买我收到"Invalid Grant"错误.尝试用php客户端库刷新并用curl手动刷新.
这是手动卷曲:
$oauth2token_url = "https://accounts.google.com/o/oauth2/token";
$clienttoken_post = array(
"client_id" => 'xxxxxxxx-d28qutrse5bvaf7n4a37qgs5ieijvp9n.apps.googleusercontent.com',
"client_secret" => 'xxxxxxxxxxxxx');
$clienttoken_post["refresh_token"] = $refresh_token;
$clienttoken_post["grant_type"] = "refresh_token";
$curl = curl_init($oauth2token_url);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $clienttoken_post);
curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
$json_response = curl_exec($curl);
curl_close($curl);
$authObj = json_decode($json_response);
print_r($authObj);
exit();
Run Code Online (Sandbox Code Playgroud)
我使用simple.php示例在之前的调用中获得的刷新令牌:
require_once '../../src/apiClient.php';
require_once '../../src/contrib/apiAnalyticsService.php';
session_start();
$client = new apiClient();
$client->setApplicationName("Google Analytics PHP Starter Application");
// Visit https://code.google.com/apis/console?api=analytics to generate your
// client id, client secret, and to register your …Run Code Online (Sandbox Code Playgroud) 我试图连接GoogleApiClient与Games.API和Auth.GOOGLE_SIGN_IN_API(用于获取用户资料信息).
得到此错误:
java.lang.IllegalStateException: Auth.GOOGLE_SIGN_IN_API cannot be used with Games.API
Run Code Online (Sandbox Code Playgroud)
码:
GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
.requestProfile()
.build();
googleApiClient = new GoogleApiClient.Builder(activity)
.addConnectionCallbacks(connectionCallbacks)
.addOnConnectionFailedListener(onConnectionFailedListener)
.addApi(Games.API).addScope(Games.SCOPE_GAMES)
.addApi(Auth.GOOGLE_SIGN_IN_API, gso)
.build();
Run Code Online (Sandbox Code Playgroud)
为什么我不能用Games.API有Auth.GOOGLE_SIGN_IN_API?
我有什么选择连接Games.API并获取用户档案信息?
使用Google Sheets API python如何dropdown list使用list items[是] 添加到谷歌工作表.不,可能会邀请朋友,他们是否会参加活动.
我在这里查看了google开发者工作表api文档,但未提供任何示例.
寻找JSON结构.
结果将是这样的:
谢谢!
我一直在尝试使用Google App Engine,我正在尝试导入某些库以执行API命令.然而,我一直无法导入.当我尝试执行"来自apiclient.discovery import build"时,我的网站不再加载.当我在IDLE中进行本地测试时,此命令有效.
python google-app-engine google-api google-api-client google-api-python-client
我有一些代码连接到GoogleApiClient但是没有调用onConnected.
public class MainActivity extends Activity implements GoogleApiClient.ConnectionCallbacks, GoogleApiClient.OnConnectionFailedListener {
private GoogleApiClient mApiClient;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
initGoogleApiClient();
}
private void initGoogleApiClient() {
mApiClient = new GoogleApiClient.Builder( this )
.addApi( Wearable.API )
.build();
mApiClient.connect(); // On completion onConnected() will be called
}
@Override
public void onConnected(Bundle bundle) {
}
@Override
public void onConnectionSuspended(int i) {
}
@Override
protected void onDestroy() {
super.onDestroy();
mApiClient.disconnect();
}
@Override
public void onConnectionFailed(com.google.android.gms.common.ConnectionResult connectionResult) {
}
Run Code Online (Sandbox Code Playgroud)
四个@Override方法都没有被调用,为什么会这样?
为什么我的情况是“找不到 import com.google.api.client.googleapis.extensions ”?我正在使用 android studio,android sdk 1.7。我还添加了依赖项:
compile 'com.google.android.gms:play-services:9.4.0'
compile 'com.google.api-client:google-api-client:1.19.0' exclude module: 'httpclient'
compile 'com.google.http-client:google-http-client-gson:1.19.0' exclude module: 'httpclient'
Run Code Online (Sandbox Code Playgroud)
多谢!
我试图将Google地图加载到片段中.我不知道这三行应该是什么......(三行注释"问题!").
大多数例子在括号中使用"this".我知道这是一个片段,而不是一个活动,所以我用"getActivity()"代替.但是,如果我将所有三行更改为getActivity(),它也不起作用.请帮忙!提前致谢!
public class MapFragment extends Fragment implements OnMapReadyCallback,GoogleApiClient.ConnectionCallbacks,
GoogleApiClient.OnConnectionFailedListener,com.google.android.gms.location.LocationListener {
private static final String TAG = "***MapFragment***";
private final int PERMISSION_CODE = 1;
private GoogleApiClient myGoogleApiClient;
private GoogleMap myMap;
private Location curLocation;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
return inflater.inflate(R.layout.fragment_target, container, false);
// create api client
if (myGoogleApiClient == null) {
myGoogleApiClient = new GoogleApiClient.Builder(getActivity()) // problem!
.addConnectionCallbacks(this) // problem! …Run Code Online (Sandbox Code Playgroud)