File tree Expand file tree Collapse file tree 2 files changed +19
-0
lines changed Expand file tree Collapse file tree 2 files changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -12,6 +12,10 @@ static void Main(string[] args)
12
12
{
13
13
Client client = new Client ( ) ;
14
14
15
+ client . setCredentials ( "mabako" , "" ) ;
16
+ Console . WriteLine ( "Logged in as: {0}" , client . getCurrentUser ( ) ) ;
17
+
18
+ Console . WriteLine ( ) ;
15
19
Console . WriteLine ( "Repositories of mabako?" ) ;
16
20
client . getRepositories ( "mabako" ) . ToList ( ) . ForEach ( repo => Console . WriteLine ( " {0}" , repo . Name ) ) ;
17
21
Original file line number Diff line number Diff line change @@ -110,5 +110,20 @@ public IList<Repository> getOrganizationRepositories(string organization)
110
110
list . ForEach ( r => { r . _client = client ; r . Organization = org ; } ) ;
111
111
return list ;
112
112
}
113
+
114
+ /// <summary>
115
+ /// Retrieves the current user.
116
+ ///
117
+ /// Requires to be logged in (OAuth/User+Password).
118
+ /// </summary>
119
+ /// <returns>current user</returns>
120
+ public User getCurrentUser ( )
121
+ {
122
+ if ( client . Authenticator == null )
123
+ throw new ArgumentException ( "no authentication details" ) ;
124
+
125
+ var request = new RestRequest ( "/user" ) ;
126
+ return client . Get < User > ( request ) . Data ;
127
+ }
113
128
}
114
129
}
You can’t perform that action at this time.
0 commit comments