/// Request Oauth2 credentials through Google.
        public OAuth2CredentialRequest(ClientSecrets secrets, IEnumerable <string> scopes,
                                       string callbackPath, IDataStore dataStore)
        {
            // Use Google authorization code flow, which has hardcoded authorization server and token server
            // URLs.
            IsGoogle = true;
            var initializer = new GoogleAuthorizationCodeFlow.Initializer {
                ClientSecrets = secrets,
                Scopes        = scopes,
                DataStore     = dataStore,
            };
            var authFlow     = new GoogleAuthorizationCodeFlow(initializer);
            var codeReceiver = new LocalHttpCodeReceiver(callbackPath);

            m_AppFlow = new AuthorizationCodeInstalledApp(authFlow, codeReceiver);
        }
Exemple #2
0
        /// Request Oauth2 credentials through a third party by providing authorization and token server
        /// URLs.
        public OAuth2CredentialRequest(ClientSecrets secrets, IEnumerable <string> scopes,
                                       string callbackPath, IDataStore dataStore,
                                       string authorizationServerUrl, string tokenServerUrl)
        {
            Debug.Assert(!string.IsNullOrWhiteSpace(authorizationServerUrl),
                         "Missing authorization server url");
            Debug.Assert(!string.IsNullOrWhiteSpace(tokenServerUrl),
                         "Missing token server url");

            // Use the generic authorization code flow with the provided authorization and token
            // server urls.
            IsGoogle = false;
            var initializer = new AuthorizationCodeFlow.Initializer(authorizationServerUrl,
                                                                    tokenServerUrl)
            {
                ClientSecrets = secrets,
                Scopes        = scopes,
                DataStore     = dataStore,
            };
            var authFlow     = new AuthorizationCodeFlow(initializer);
            var codeReceiver = new LocalHttpCodeReceiver(callbackPath);

            m_AppFlow = new AuthorizationCodeInstalledApp(authFlow, codeReceiver);
        }