Example #1
0
        /// <summary>
        /// Checks the validity of an OAuth token without running afoul of normal rate limits for failed login attempts.
        /// </summary>
        /// <remarks>
        /// This method requires authentication.
        /// See the <a href="https://developer.github.com/v3/oauth_authorizations/#check-an-authorization">API documentation</a> for more information.
        /// </remarks>
        /// <param name="clientId">Client ID of the OAuth application for the token</param>
        /// <param name="accessToken">The OAuth token to check</param>
        /// <returns>The valid <see cref="ApplicationAuthorization"/>.</returns>
        public async Task <ApplicationAuthorization> CheckApplicationAuthentication(string clientId, string accessToken)
        {
            Ensure.ArgumentNotNullOrEmptyString(clientId, "clientId");
            Ensure.ArgumentNotNullOrEmptyString(accessToken, "accessToken");

            var endpoint = ApiUrls.ApplicationAuthorization(clientId, accessToken);

            return(await ApiConnection.Get <ApplicationAuthorization>(
                       endpoint,
                       null));
        }
Example #2
0
        /// <summary>
        /// Revokes a single OAuth token for an OAuth application.
        /// </summary>
        /// <remarks>
        /// This method requires authentication.
        /// See the <a href="https://developer.github.com/v3/oauth_authorizations/#revoke-an-authorization-for-an-application">API documentation for more information.</a>
        /// </remarks>
        /// <param name="clientId">ClientID of the OAuth application for the token</param>
        /// <param name="accessToken">The OAuth token to revoke</param>
        /// <returns>A <see cref="Task"/> for the request's execution.</returns>
        public Task RevokeApplicationAuthentication(string clientId, string accessToken)
        {
            Ensure.ArgumentNotNullOrEmptyString(clientId, nameof(clientId));
            Ensure.ArgumentNotNullOrEmptyString(accessToken, nameof(accessToken));

            var requestData = new
            {
                access_token = accessToken
            };

            var endpoint = ApiUrls.ApplicationAuthorization(clientId);

            return(ApiConnection.Delete(endpoint, requestData));
        }
Example #3
0
        public Task <ApplicationAuthorization> ResetApplicationAuthentication(string clientId, string accessToken)
        {
            Ensure.ArgumentNotNullOrEmptyString(clientId, nameof(clientId));
            Ensure.ArgumentNotNullOrEmptyString(accessToken, nameof(accessToken));

            var requestData = new
            {
                access_token = accessToken
            };

            var endpoint = ApiUrls.ApplicationAuthorization(clientId);

            return(ApiConnection.Patch <ApplicationAuthorization>(endpoint, requestData, AcceptHeaders.OAuthApplicationsPreview));
        }