def get(self, request): security = ESI.get_security() tokens = security.auth(request.GET['code']) data = security.verify() login(request, authenticate(request, info=data, tokens=tokens)) return redirect('/')
def post(self, request): scopes = [ 'esi-location.read_location.v1', 'esi-ui.write_waypoint.v1', ] if "approve" in request.POST: scopes.extend([ 'esi-search.search_structures.v1', 'esi-universe.read_structures.v1' ]) return redirect(ESI.get_security().get_auth_uri(state=str(uuid4()), scopes=scopes))
def post(self, request): form = ScopeForm(request.POST) if not form.is_valid(): return redirect('/') scopes = [] if form.cleaned_data['scope_open_window']: scopes.append('esi-ui.open_window.v1') if form.cleaned_data['scope_read_assets']: scopes.append('esi-assets.read_assets.v1') return redirect(ESI.get_security().get_auth_uri(scopes=scopes))
def get_security(self): res = ESI.get_security() res.update_token(self.tokens) if res.is_token_expired(offset=60): try: self.tokens = res.refresh() except APIException as e: if e.status_code == 400: self.scope_open_window = False self.scope_read_assets = False self.save() raise EveUser.KeyDeletedException( "ESI refused to refresh our tokens." ) raise return res