Giter Club home page Giter Club logo

go-oauth2-example's Introduction

go-oauth2-example

This example will show you how you can create an OAuth2 server. In this case, only for playing with the code I choose the Fiber framework, but the truth is that the oauth2 library that I used here was written to be used with the standard net/http and that is not the case with Fiber.

These are the URLs available in this project and the purpose of each one:

Is only to show that the server is running right:

http://localhost:3000/

Will return the credentials (the client ID and the client secret) necessary to get the token:

http://localhost:3000/credentials

Will return the token related to a client ID (you need pass also the client secret):

http://localhost:3000/token?grant_type=client_credentials&client_id=CLIENT_ID&client_secret=CLIENT_SECRET

Example: (in this case your client ID is: 1081abb7, and your client secret is: 3f64ebed)

http://localhost:3000/token?grant_type=client_credentials&client_id=1081abb7&client_secret=3f64ebed

This URL is protected, you only should have access if you have the right token:

http://localhost:3000/protected?access_token=TOKEN

Example: (in this case your token is: NWE1YJQ0NMUTMZVIMY0ZNMRLLWJJNJKTNMI5MMZIMJRKMZUX)

http://localhost:3000/protected?access_token=NWE1YJQ0NMUTMZVIMY0ZNMRLLWJJNJKTNMI5MMZIMJRKMZUX

If you want to test the server, you need to clone this repository and in the root folder run the server with this command:

go run ./main.go

This example was written for this post on my blog: 'Build your own oauth2 server'

go-oauth2-example's People

Contributors

jackgris avatar

Watchers

 avatar

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.