public void CanCreateAndRemoveOAuthToken()
        {
            var request = new CreateAuthorizationTokenRequest
               {
                   ClientId = _clientId,
                   ClientSecret = _clientsecret,
                   Note = "NUnitTest",
                   Scopes = new[] { "user", "repo" }
               };
            var response = _authrepo.CreateNewAuthToken(request);
            Assert.IsNotNull(response);
            Assert.IsNotEmpty(response.Scopes);
            Assert.True(response.Scopes.Any(s => s == "user"));
            Assert.IsNotNull(response.App);
            Assert.AreEqual("githubsharp", response.App.Name.ToLowerInvariant());

            _authrepo.RemoveAuthToken(response.Id);
            //assert they are gone
            var tokens = _authrepo.GetTokens();
            Assert.IsFalse(tokens.Any(t => t.Id == response.Id));
        }
Exemplo n.º 2
0
 /// <summary>
 /// Note I believe this can only be used with basic authtication provider.
 /// Please also note this request is NOT idempotent. Multiple request will create multiple auth tokens!
 /// </summary>
 /// <returns></returns>
 public AuthorizationToken CreateNewAuthToken(CreateAuthorizationTokenRequest request)
 {
     return ConsumeJsonUrlAndPostData<CreateAuthorizationTokenRequest, AuthorizationToken>("authorizations", request);
 }