oAuthを使用してSalesforceにGoogleドライブ統合を作成することができました。しかし、私の問題は、アプリがGoogleにログインするようにユーザーをリダイレクトすることです。私はプログラムでログインして、すべてのユーザーが同じGoogleドライブユーザーとして自動的にログインするようにします。これを行う唯一の方法は、Googleドライブのサービスアカウントを使用することだと思います。ドキュメントを見ている以外は、Apexでこれを設定する方法はわかりません。ここでのJavaを示しドキュメントされていますGoogleドライブとSalesforceとの統合サービスアカウントを使用
https://developers.google.com/identity/protocols/OAuth2ServiceAccount#authorizingrequests
ここでは、OAuthのために動作します(ただし、Googleにログインする必要があります私の認証URIです:
global class cAuthURIForApiReq {
global String authenticationURI = '';
public cAuthURIForApiReq(String clientKey, String redirect_uri) {
String key = EncodingUtil.urlEncode(clientKey, 'UTF-8');
String uri = EncodingUtil.urlEncode(redirect_uri, 'UTF-8');
String authuri = 'https://accounts.google.com/o/oauth2/v2/auth?' +
'client_id=' + key +
'&response_type=code' +
'&scope=https://www.googleapis.com/auth/drive' +
'&redirect_uri=' + uri +
'&state=security_token%3D138r5719ru3e1%26url%3Dhttps://oauth2-login-demo.example.com/myHome' +
'&[email protected]' +
'&access_type=offline';
authenticationURI = authuri;
}
}
そしてへこのメソッドを呼び出すだけで認証できます:
public PageReference driveAuth() {
PageReference pg = new PageReference(new cAuthURIForApiReq(key, redirect_uri).authenticationURI);
return pg;
}
誰でもログインするようにGoogleにリダイレクトせずにプログラムで認証する方法を知っていますか?