I want to authenticate GitHub user to my GitHub application and serve to my local server 127.0.0.1:8000, but I am not able to take tokens.
This is how GitHub is showing authentication.
From GitHub documentation, I am not able to understand the process of authentication after generating private key, then how to create JWT and installation tokens ?
Could someone show me what to do next ?
score:0
You can follow "Obtaining an Access Token from a GitHub Application Webhook" (Jerrie Pelser), which itself takes from "JWT RSA & HMAC + ASP.NET Core" from Piotr Gankiewicz
Jerrie mentions as first step to convert your PEM file to XML format.
You can use an online tool or write a class
And you need your GitHub application Id:
You will find in the article the class JwtSecurityTokenHandler
used to create the JSON Web Token from the XML key.
@api_view(['POST'])
@permission_classes([AllowAny, ])
def authenticate_user(request):
try:
email = request.data['email']
password = request.data['password']
user = User.objects.get(email=email, password=password)
if user:
try:
payload = jwt_payload_handler(user)
token = jwt.encode(payload, settings.SECRET_KEY)
user_details = {}
user_details['name'] = "%s %s" % (
user.first_name, user.last_name)
user_details['token'] = token
user_logged_in.send(sender=user.__class__,
request=request, user=user)
return Response(user_details, status=status.HTTP_200_OK)
except Exception as e:
raise e
else:
res = {
'error': 'can not authenticate with the given credentials or the account has been deactivated'}
return Response(res, status=status.HTTP_403_FORBIDDEN)
except KeyError:
res = {'error': 'please provide a email and a password'}
return Response(res)
Credit To: stackoverflow.com
Related Query
- GitHub user authentication in GitHub application through Django framework
- User Authentication in Django Rest Framework + Angular.js web app
- How should I be implementing user SSO with AAD in a Django application (using the Django Microsoft Authentication Backend module)?
- Upload user file to google drive through django web application
- Django Rest Framework Token Authentication for Custom User Model
- Django Rest Framework user authentication
- django rest framework and react native user authentication with undefined response
- Django rest framework with djoser token authentication retrieve user first_name
- Django Rest Framework User and UserRole and Permission Handling using Token Authentication
- Django Rest Framework authentication and user session
- Django unique "username" when using local user authentication and "Django Social auth" application
- User current authentication status check endpoint with django and django rest framework
- Django Rest Framework - Authentication credentials were not provided
- Django Rest Framework Token Authentication
- Return the current user with Django Rest Framework
- Using Basic HTTP access authentication in Django testing framework
- Django setting : psycopg2.OperationalError: FATAL: Peer authentication failed for user "indivo"
- Django Rest Framework custom authentication
- Django Rest Framework Postman Token Authentication
- How to create a new user with django rest framework and custom user model
- Get Authenticated user from token in Django Rest Framework
- Why does Django REST Framework provide different Authentication mechanisms
- How to use Graphene GraphQL framework with Django REST Framework authentication
- Django REST Framework (DRF): Set current user id as field value
- Django REST Framework Creating custom user
- django rest framework lookup_field through OneToOneField
- How to do Django JSON Web Token Authentication without forcing the user to re-type their password?
- How do you Serialize the User model in Django Rest Framework
- One-Time User Authentication with SMS Using Django and Twilio
- Testing authentication in Django Rest Framework Views -- Cannot authenticate when testing
More Query from same tag
- serializing two different models with django
- I'm having trouble with my bootstrap cdn in pycharm it's making my website look ugly lol
- Django - ForeignKey issue. How many DB accesses?
- How to format a number in django and respect localization
- Securing Django OAuth Toolkit Views
- django+gunicorn+nginx, django admin return 504 Gateway Time-out
- How to fix Django South issue with regards to localflavor in Django 1.5?
- Django - Repeating a form field n times in one form
- Delete user directly from html template
- Where is the SQLite database created automatically by django?
- jQuery tablesorter sorting formatted currency
- Verify mail was sent from unit tests
- Django Management Command not workingcif i run for loop
- how to see all celery tasks pushed in rabbitmq queue
- django database codec