GithubHelp home page GithubHelp logo

Comments (6)

stevejonpeters avatar stevejonpeters commented on September 18, 2024

https://forums.aws.amazon.com/thread.jspa?messageID=767716 here is the issue from 2017

from aws-data-lake-solution.

stevejonpeters avatar stevejonpeters commented on September 18, 2024

is this a CORS issue? the datalakeweb bucket does not have CORS enabled.

from aws-data-lake-solution.

ericquinones avatar ericquinones commented on September 18, 2024

We apologize for the inconvenience. We are currently researching the issue on our end. Please continue to monitor the repository for updates.

from aws-data-lake-solution.

ericquinones avatar ericquinones commented on September 18, 2024

Hi @stevejonpeters -
Below is an example of constructing an API call to v2.1.0 of Data Lake that was tested on the Python 3.7 Lambda runtime using requests v2.22.0. The API returns a 200 status code with a JSON payload as the response body.

The commented lines in getSignatureKey are the JavaScript versions of the code from our API documentation.

The access_key and secret_key needed to generate the signing key will both come from the Data Lake console (details here) so there should be no need to compare with Cognito.

Can you please compare the below with how you are constructing the signing key and the API request?

import os, base64, datetime, hashlib, hmac 
import requests

def getSignatureKey(accessKey, secretKey, dateStamp, apiEndpoint):
    # let kDate = crypto.createHmac('sha256', "DATALAKE4" + secretKey);
    # kDate.update(moment().utc().format("YYYYMMDD"));
    kDate = hmac.new(f"DATALAKE4{secretKey}".encode('utf-8'), dateStamp.encode('utf-8'), hashlib.sha256)
    
    # let kEndpoint = crypto.createHmac('sha256', kDate.digest('base64'));
    # kEndpoint.update(apiEndpoint);
    kEndpoint = hmac.new(base64.b64encode(kDate.digest()), apiEndpoint.encode('utf-8'), hashlib.sha256)

    # let kService = crypto.createHmac('sha256', kEndpoint.digest('base64'));
    # kService.update('datalake');
    kService = hmac.new(base64.b64encode(kEndpoint.digest()), "datalake".encode('utf-8'), hashlib.sha256)

    # let kSigning = crypto.createHmac('sha256', kService.digest('base64'));
    # kSigning.update("datalake4_request");
    kSigning = hmac.new(base64.b64encode(kService.digest()), "datalake4_request".encode('utf-8'), hashlib.sha256)

    # let _signature = kSigning.digest('base64');
    _signature = base64.b64encode(kSigning.digest()).decode('utf-8')

    # let _apiKey = [accessKey, _signature].join(':');
    # let _authKey = Base64.encode(_apiKey);
    _apiKey = ":".join([accessKey, _signature])
    _authKey = base64.b64encode(_apiKey.encode('utf-8')).decode('utf-8')

    # return ['ak', _authKey].join(':');
    return ":".join(["ak", _authKey])

access_key = os.environ.get('KEY')
secret_key = os.environ.get('SECRET')
api_endpoint = os.environ.get('API_ENDPOINT')

sign_key = getSignatureKey(access_key, secret_key, datetime.datetime.utcnow().strftime('%Y%m%d'), api_endpoint)

headers = {'Auth':sign_key}

request_url = f"https://{api_endpoint}/prod/search?term=test"

r = requests.get(request_url, headers=headers)

print(f"Response code: {r.status_code}")
print(r.text)

from aws-data-lake-solution.

knihit avatar knihit commented on September 18, 2024

Hi @stevejonpeters are you still facing this issue. Did the example provided by eric help you to find a solution. If the problem is resolved, can you please close the issue.

from aws-data-lake-solution.

georgebearden avatar georgebearden commented on September 18, 2024

Closing this issue, but please let us know if you need additional assistance.

from aws-data-lake-solution.

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.