google / gtm-oauth2

Google Toolbox for Mac - OAuth 2 Controllers
Apache License 2.0
126 stars 70 forks source link

error=access_denied after submitting user name and password in OAuth2 Process #46

Closed gpraveen closed 5 years ago

gpraveen commented 9 years ago

I am doing OAuth2 for sharepoint and onedrive using GTM but after I submitting the credentials i am getting this error frequently . Authentication error: Error Domain=com.google.GTMOAuth2 Code=-1000 "The operation couldn’t be completed. (com.google.GTMOAuth2 error -1000.)"

And for some users I am not getting this error. I am surprised why it not working for some users. And I observed one thing for any user OAuth Process is not asking accept perrmision screen. Can any one help me to find out the problem I used the same sample signInToDailyMotion code by replacing my Client ID and Secret

This is my code:

/* Copyright (c) 2011 Google Inc. *

// OAuth2SampleRootViewControllerTouch.m

import "OAuth2SampleRootViewControllerTouch.h"

import "GTMOAuth2ViewControllerTouch.h"

import "GTMOAuth2SignIn.h"

static NSString const kKeychainItemName = @"OAuth Sample: Google Contacts"; static NSString const kShouldSaveInKeychainKey = @"shouldSaveInKeychain";

static NSString const kDailyMotionAppServiceName = @"OAuth Sample: DailyMotion"; static NSString const kDailyMotionServiceName = @"DailyMotion";

@implementation OAuth2SampleRootViewControllerTouch

@synthesize clientIDField = mClientIDField, clientSecretField = mClientSecretField, serviceNameField = mServiceNameField, emailField = mEmailField, expirationField = mExpirationField, accessTokenField = mAccessTokenField, refreshTokenField = mRefreshTokenField, fetchButton = mFetchButton, expireNowButton = mExpireNowButton, serviceSegments = mServiceSegments, shouldSaveInKeychainSwitch = mShouldSaveInKeychainSwitch, signInOutButton = mSignInOutButton;

@synthesize auth = mAuth;

// NSUserDefaults keys static NSString const kGoogleClientIDKey = @"GoogleClientID"; static NSString const kGoogleClientSecretKey = @"GoogleClientSecret"; static NSString const kDailyMotionClientIDKey = @"DailyMotionClientID"; static NSString const kDailyMotionClientSecretKey = @"DailyMotionClientSecret";

// UISwitch does the toggling for us. We just need to read the state.

// NSString clientID = self.clientIDField.text; // NSString clientSecret = self.clientSecretField.text;

GTMOAuth2Authentication *auth; auth = [GTMOAuth2Authentication authenticationWithServiceProvider:kDailyMotionServiceName tokenURL:tokenURL redirectURI:redirectURI clientID:clientID clientSecret:clientSecret ]; return auth; }

// // Normally an application will hardwire the client ID and client secret // strings in the source code. This sample app has to allow them to be // entered by the developer, so we'll save them across runs into preferences. //

@end