Git Product home page Git Product logo

Comments (8)

bsurmanski avatar bsurmanski commented on April 27, 2024 1

A 400 error is a client error. It's possible a step may have been missed in set up.

Did you follow the set up at: https://cloud.google.com/web-risk/docs/quickstarts
to enable the webrisk API for the cloud project associated with that API key?

from webrisk.

bsurmanski avatar bsurmanski commented on April 27, 2024 1

A few things to check:

  1. try modifying netAPI::doRequest in api.go to print the full error message from the request, not just the http status code. This line here:

    webrisk/api.go

    Line 96 in 030b4b9

    return fmt.Errorf("webrisk: unexpected server response code: %d", httpResp.StatusCode)

  2. Looks like your first error reported is 'no database file specified'. This might have cascaded the further errors. See if specifying the -db flag changes anything.

  3. I believe uris:search is part of the lookup API. It's possible there's a setup difference. Consider trying a curl of one of the methods from the Update API: https://cloud.google.com/web-risk/docs/update-api.

  4. check the wrlookup command to see if it also gives a 400 error, since it seems using curl succeeds for that command.

from webrisk.

corey-Robinson1337 avatar corey-Robinson1337 commented on April 27, 2024

Yes I'm having no issues hitting the webrisk api with that key!

image

I've also made sure that $APIKEY has the correct value

from webrisk.

corey-Robinson1337 avatar corey-Robinson1337 commented on April 27, 2024

image
3.
Running the sample request returns expected response

curl -X GET \
-H "Authorization: Bearer "$(gcloud auth application-default print-access-token) \
""https://webrisk.googleapis.com/v1/threatLists:computeDiff?threatType=MALWARE&versionToken=Gg4IBBADIgYQgBAiAQEoAQ%3D%3D&constraints.maxDiffEntries=2048&constraints.maxDatabaseEntries=4096&constraints.supportedCompressions=RAW""

image

image

For Issue one I'm not really familiar with Go. Should I make the change then run go install?

What should httpResp.StatusCode be changed to to output the appropriate error message?

from webrisk.

bsurmanski avatar bsurmanski commented on April 27, 2024

Looks like wrlookup is having problems too.

I'm on mobile rn, so can't double check, but I think the best way to modify and run the webrisk server would be to checkout the git repo, make the change, then run go run or whatever the command is. I think it would be something like go run cmd/wrserver/main.go in the webrisk directory

from webrisk.

corey-Robinson1337 avatar corey-Robinson1337 commented on April 27, 2024

alright I changed the line

from

 return fmt.Errorf("webrisk: unexpected server response code: %d", httpResp.StatusCode) 

to

 return fmt.Errorf("webrisk: unexpected server response code: %d", httpResp)

and ran the main.go script as you instructed

image

from webrisk.

bsurmanski avatar bsurmanski commented on April 27, 2024

Ahhh, I think i see the issue. I believe the API key is set incorrectly. I imagine print-access-token would give you, well, some sort of access token. Maybe oauth. But this WebRisk CLI uses API keys. I think the WebRisk API can use both access token and api key, which is why it worked with curl; but this client in this repo specifically uses api keys right now.

View your api keys by visiting the Google cloud console: https://console.cloud.google.com/apis/credentials

Make sure the API restrictions allow webrisk.

from webrisk.

corey-Robinson1337 avatar corey-Robinson1337 commented on April 27, 2024

Yeah that was it.

Perhaps the README should be updated with instructions on how to generate the api key for this sample app because if you follow the setup here https://cloud.google.com/web-risk/docs/using-sample-app

you will be instructed to first read the general setup which links to here

A brief walkthrough of how to generate the key needed for this particular project would have been very useful. Probably more useful than the entire existing quickstart guide.

from webrisk.

Related Issues (17)

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.