Giter Club home page Giter Club logo

gitter-api-auth's Introduction

gitter-api-auth

NuGet Status Build status

Gitter# Auth provide you a way to authenticate user on Gitter API. You can use Gitter# Auth on these platforms :

  • Windows 8.1 (Store Apps)
  • Windows Phone 8.1
  • Windows 10
  • .NET Framework 4.5
  • Xamarin.Android [planned]
  • Xamarin.iOS [planned]

Authentication process

The authentication is divided in 2 steps that allow you to retrieve a Gitter token. These 2 steps can be found in a single service :

public class AuthenticationService
{
    public async Task<bool?> LoginAsync(string oauthKey, string oauthSecret)
    {
        ...
    }

    public async Task<string> RetrieveTokenAsync(...)
    {
        ...
    }
}

Step 1 - Execute login

.NET Framework

string Login(string oauthKey, string oauthSecret);

Using .NET Framework, we load a browser window and once we get a result we automatically call to generate a token.

Windows 8.1 / Windows 10

Task<bool?> LoginAsync(string oauthKey, string oauthSecret);

On Windows 8.1 / 10 and Windows Phone 8.1, the login process use a service called WebAuthenticationBroker through OAuth2. This method requires your OauthKey and your OauthSecret. You can retrieve these parameters from the developer website : https://developer.gitter.im/docs/authentication.

Step 2 - Retrieve token

.NET Framework

For example, using a C# console application :

private static string _oauthKey = "<key>";
private static string _oauthSecret = "<secret>";

[STAThread]
static void Main(string[] args)
{
    var authenticationService = new AuthenticationService();
    string token = authenticationService.Login(_oauthKey, _oauthSecret);

    // Now you can use the token with the Gitter Api

    Console.WriteLine("Press any key to exit.");
    Console.ReadKey();
}

Windows 8.1 / Windows 10

Task<string> RetrieveTokenAsync();

On Windows 8.1 / 10, once you're authenticated (cf. step 1), you only have to retrieve the provided token as it is.

Windows Phone 8.1

Task<string> RetrieveTokenAsync(WebAuthenticationBrokerContinuationEventArgs args);

On Windows Phone 8.1, it is a little different, you have to pass a parameter : WebAuthenticationBrokerContinuationEventArgs. This event result comes from the continuation service of the WebAuthenticationBroker.

Here is an example of how to implement OAuth2 authentication using WebAuthenticationBroker on Universal Apps (W8.1 / WP8.1) : https://code.msdn.microsoft.com/windowsapps/Authentication-using-bb28840e#content.

gitter-api-auth's People

Contributors

odonno avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

gitter-api-auth's Issues

Method to clear cookies of the WebBrowser control

I am having an issue I initially used a bad oauth Redirect URL, (at least I think this is the source of that issue) and I am as a result, unable to actually get a token. and instead the browser control fails to pass the token back to the application.

My working theory as of right now is that a cookie got set in the first session which is causing this issue.
screenshot 81

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.