public async Task Test_ReturnsToken() { var provider = new DefaultTokenProvider("my-token"); var tokenAsync = await provider.GetTokenAsync(); Assert.AreEqual("my-token", tokenAsync); }
public async System.Threading.Tasks.Task InitializeAsyncTestAsync() { var path = "http://localhost:3000#access_token=mah.token&token_type=Bearer&expires_in=3600&scope=lots%20of%20scopes"; var uri = new Uri(path); var provider = new DefaultTokenProvider(); await provider.InitializeAsync(uri.Fragment); Assert.IsTrue(provider.IsInitialized); Assert.IsNotNull(provider.Token); }
public async Task Test_InitialiseWithCustomProvider() { var provider = new DefaultTokenProvider("my-token"); var options = new GithubClientOptions(provider); Assert.AreEqual(provider, options.TokenProvider, "Token provider instance used."); var token = await options.TokenProvider.GetTokenAsync(); Assert.AreEqual("my-token", token, "Retrieves provided token."); }
/// <summary> /// Initialise a new instance of the <see cref="GithubClientOptions"/> class with a default <see cref="ITokenProvider"/> using the given <paramref name="apiKey"/>. /// </summary> /// <param name="apiKey"></param> public GithubClientOptions(string apiKey) { TokenProvider = new DefaultTokenProvider(apiKey); }