Ejemplo n.º 1
0
        public HubSpotToken Refresh(string redirectUri, HubSpotToken token)
        {
            RequestRefreshTokenHubSpotModel model = new RequestRefreshTokenHubSpotModel()
            {
                ClientId     = ClientId,
                ClientSecret = _clientSecret,
                RedirectUri  = redirectUri,
                RefreshToken = token.RefreshToken
            };

            HubSpotToken refreshToken = InitiateRequest(model, _client.BasePath);

            _client.UpdateToken(refreshToken);
            return(refreshToken);
        }
Ejemplo n.º 2
0
        public HubSpotToken Authorize(string redirectCode, string redirectUri)
        {
            RequestTokenHubSpotModel model = new RequestTokenHubSpotModel()
            {
                ClientId     = ClientId,
                ClientSecret = _clientSecret,
                RedirectCode = redirectCode,
                RedirectUri  = redirectUri
            };

            HubSpotToken token = InitiateRequest(model, _client.BasePath);

            _client.UpdateToken(token);
            return(token);
        }
Ejemplo n.º 3
0
        public async Task <HubSpotToken> RefreshAsync(string redirectUri, HubSpotToken token, CancellationToken cancellationToken = default)
        {
            RequestRefreshTokenHubSpotModel model = new RequestRefreshTokenHubSpotModel()
            {
                ClientId     = ClientId,
                ClientSecret = _clientSecret,
                RedirectUri  = redirectUri,
                RefreshToken = token.RefreshToken
            };

            HubSpotToken refreshToken = await InitiateRequestAsync(model, _client.BasePath, cancellationToken);

            await _client.UpdateTokenAsync(refreshToken, cancellationToken);

            return(refreshToken);
        }
Ejemplo n.º 4
0
        public async Task <HubSpotToken> AuthorizeAsync(string redirectCode, string redirectUri, CancellationToken cancellationToken = default)
        {
            RequestTokenHubSpotModel model = new RequestTokenHubSpotModel()
            {
                ClientId     = ClientId,
                ClientSecret = _clientSecret,
                RedirectCode = redirectCode,
                RedirectUri  = redirectUri
            };

            HubSpotToken token = await InitiateRequestAsync(model, _client.BasePath, cancellationToken);

            await _client.UpdateTokenAsync(token, cancellationToken);

            return(token);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Creates a HubSpotApi using OAuth 2.0 authentication for all API calls.
        /// </summary>
        /// <param name="clientId"></param>
        /// <param name="clientSecret"></param>
        /// <param name="appId"></param>
        /// <param name="token"></param>
        public HubSpotApi(string clientId, string clientSecret, string appId, HubSpotToken token = null)
        {
            IHubSpotClient client = new HubSpotBaseClient(string.Empty, HubSpotAuthenticationMode.OAUTH, appId, token);

            InitializeRepos(client, clientId, clientSecret);
        }