Giter VIP home page Giter VIP logo

Comments (2)

derekbekoe avatar derekbekoe commented on July 28, 2024

I wasn't able to reproduce this for a tunnel-port with anonymous access enabled.
The authorization is received as expected by the server.

You mentioned http://tunnel-address:80/path1/path2. One change you can try is to remove :80 and use https://tunnel-address/path1/path2 instead.

Here's the steps I used.

Client using node-fetch:

const fetch = require('node-fetch');

const url = 'https://tunnelid-3000.usw2.devtunnels.ms/endpoint';
const authToken = 'your-auth-token';

fetch(url, {
  headers: {
    Authorization: `Bearer ${authToken}`,
    accept: 'application/json'
  }
})
  .then(response => console.log(response))
  .then(data => {
    // Handle the response data here
    console.log(data);
  })
  .catch(error => {
    // Handle any errors that occurred during the request
    console.error(error);
  });

Server-side code:

# python3 -m pip install flask
from flask import Flask, request

app = Flask(__name__)

@app.route('/endpoint', methods=['GET'])
def endpoint():
    # Get the Authorization header
    auth_header = request.headers.get('Authorization')
    # Check if the header exists and starts with 'Bearer '
    if auth_header and auth_header.startswith('Bearer '):
        # Extract the token value
        token = auth_header.split(' ')[1]
        # Print the token to the console
        print("token:", token)
        return 'Token received and processed successfully'
    else:
        return 'Invalid Authorization header', 401

if __name__ == '__main__':
    app.run(port=3000)

from dev-tunnels.

derekbekoe avatar derekbekoe commented on July 28, 2024

Closing as stale.

from dev-tunnels.

Related Issues (20)

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.