Senaryo: Google+ GirişiGoogle Plus Girişi
Uygulama aracılığıyla App Girişi:
- (void)viewDidLoad {
[super viewDidLoad];
GPPSignIn *aGPSSignIn = [GPPSignIn sharedInstance];
aGPSSignIn.scopes = @[ kGTLAuthScopePlusLogin, kGTLAuthScopePlusUserinfoEmail, kGTLAuthScopePlusUserinfoProfile, kGTLAuthScopePlusMe];
aGPSSignIn.shouldFetchGoogleUserEmail = YES;
aGPSSignIn.shouldFetchGooglePlusUser =YES;
aGPSSignIn.homeServerClientID = kClientID;
aGPSSignIn.clientID = kClientID;
aGPSSignIn.delegate = self;
if (![aGPSSignIn trySilentAuthentication]) {
[self showLoginButton];
}
}
- (void)showLoginButton {
if (!self.signInButton) {
self.signInButton = [GPPSignInButton buttonWithType:UIButtonTypeCustom];
[self.signInButton setFrame:CGRectMake(60, 100, 200, 40)];
}
[self.view addSubview:self.signInButton];
}
#pragma mark - GPPSignInDelegate
- (void)finishedWithAuth: (GTMOAuth2Authentication *)auth error: (NSError *) error {
NSString *anAccessToken = auth.accessToken;
NSLog(@"googleAccessToken:%@",anAccessToken);
}
- (void)didDisconnectWithError:(NSError *)iError {
if (iError) {
NSLog(@"Error:%@", iError);
}
}
Not: - (BOOL)application: (UIApplication *)application openURL: (NSURL *)url sourceApplication:(NSString *)sourceApplication annotation: (id)annotation
AppDelegate içinde ele alınır.
Sayı:
- kullanıcı Google imzalaması Düğmesi tıkladığında ve Safari için gidilen, Google+ giriş mükemmel çalışıyor. Uygulamamda geçerli bir AccessToken alındı.
- Ancak, Google+ uygulaması iPhone'da mevcutsa, kullanıcı Google+ uygulamasına yönlendirilir, ancak Giriş yapmadan AccessToken alınır. Bir hata alıyorum.
Hata: Birisi bu sorunu çözmede bana yol eğer
Received error Error Domain=com.google.GooglePlusPlatform Code=-1 "The operation couldn’t be completed. (com.google.HTTPStatus error 400.)" UserInfo=0x15d95f90 {NSLocalizedDescription=The operation couldn’t be completed. (com.google.HTTPStatus error 400.)} and auth object (null)
Çok yararlı olacaktır. Teşekkürler.
Uygulamanızı yaptınız mı? Google Geliştirici Konsolu'nda grup kimliği var mı? Bu, Google+ API'daki WebView veya Safari uygulamasının uygulamayı başlatmasının tek yolu. – khunshan
Evet Yaptım ama yine de hata aynı kalıyor. – Nishi
@Nishi Çözümünüz var mı? Aynı sorunla karşı karşıyayım http://stackoverflow.com/questions/30160104/authentication-not-working-with-google-app – Tariq