Skip to content

Instantly share code, notes, and snippets.

View CryceTruly's full-sized avatar
🎯
Focusing

cryce truly CryceTruly

🎯
Focusing
View GitHub Profile
import hmac
import hashlib
import json
def makeHash():
secret = "zzdfQr_HSb41O-chk9MEDDeLr_snDO3EiEZ6i5IEwZkgEwdF0W3VTtIHIQsEx-TQe1TZHesmcRGnS5Ss9MyCDw"
payload = json.dumps(
{
"phone_number": "254787876541",
# messages
MESSAGE_TAGS = {
messages.ERROR: 'danger'
}
{% if messages%} {% for message in messages%}
<div class="alert alert-{{message.tags}}">{{message}}</div>
{%endfor%} {% endif %}
<html>
<head>
<title>developers</title>
<link
rel="stylesheet"
href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css"
/>
</head>
SWAGGER_SETTINGS = {
'USE_SESSION_AUTH': True,
'REFETCH_SCHEMA_ON_LOGOUT': True,
'LOGIN_URL': '/',
'LOGOUT_URL': '/logout',
'SECURITY_DEFINITIONS': {
'Bearer': {
'type': 'apiKey',
'name': 'Authorization',
'in': 'header'
path('', WelcomeView.as_view(), name='welcome'),
path('logout/', LogoutView.as_view(), name='logout'),
path('swagger/api.json', schema_view.without_ui(cache_timeout=0), name='schema-json'),
path('swagger', schema_view.with_ui('swagger', cache_timeout=0), name='api-documentation'),
path('redoc', schema_view.with_ui('redoc', cache_timeout=0), name='schema-redoc'),
from rest_framework import permissions
from drf_yasg.views import get_schema_view
from drf_yasg import openapi
from drf_yasg.generators import OpenAPISchemaGenerator
from rest_framework.authentication import SessionAuthentication
class CustomOpenAPISchemaGenerator(OpenAPISchemaGenerator):
class LogoutView(View):
def get(self, request):
logout(request)
return redirect('welcome')
class WelcomeView(View):
def get(self, request):
if request.user.is_authenticated:
return redirect('api-documentation')
~<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
import AsyncStorage from '@react-native-async-storage/async-storage';
import axios, {AxiosError} from 'axios';
import {logOutUserLocal} from 'redux/actions/auth/logout/clearAllUser';
import store from 'redux/store';
import envs from 'config/env';
// Getting token from local Storage
async function getLocalToken() {
const token = await AsyncStorage.getItem('token');
return `Bearer ${token}`;