Coder Social home page Coder Social logo

getting unauthorised error about cloudant-spring HOT 7 CLOSED

ibm avatar ibm commented on June 15, 2024
getting unauthorised error

from cloudant-spring.

Comments (7)

emlaver avatar emlaver commented on June 15, 2024

Hi @zedherle, the URL in the CouchDbException error message (https://2a6085c6-394e-4a69-8074-6334f6b0c91a-bluemix.cloudant.com:443/) doesn't match the URL in your application.properties (https://ca5401d9-c380-428e-acd9-bf4621b73e26-bluemix.cloudantnosqldb.appdomain.cloud). Could you verify that your code is getting the expected URL, username, and password from your application.properties file?

from cloudant-spring.

zedherle avatar zedherle commented on June 15, 2024

Hi, i looked at the app property, indeed its a wrong url... but it should ideally pick it from there right? however i see them as "unused property", am i missing something? i am using idea community edition.

cloudant.url=https://ca5401d9-c380-428e-acd9-bf4621b73e26-bluemix.cloudantnosqldb.appdomain.cloud/_all_dbs
cloudant.username=
cloudant.password=

from cloudant-spring.

zedherle avatar zedherle commented on June 15, 2024

i am infact getting this error : 2020-10-02 16:40:25.245 ERROR 13756 --- [nio-8081-exec-4] o.a.c.c.C.[.[.[/].[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is com.cloudant.client.org.lightcouch.CouchDbException: Error retrieving server response at https://null.cloudant.com:443/_all_dbs.] with root cause

should the property be cloudant.account or cloudant.url ? - i tried both though... (documentation has both as well)

from cloudant-spring.

ricellis avatar ricellis commented on June 15, 2024

Since you have the cloudantnosqldb.appdomain.cloud domain you should use cloudant.url
i.e.
cloudant.url=https://ca5401d9-c380-428e-acd9-bf4621b73e26-bluemix.cloudantnosqldb.appdomain.cloud

cloudant.account takes the account and inserts it into https://<account>.cloudant.com
so the expectation would be something like
cloudant.account=ca5401d9-c380-428e-acd9-bf4621b73e26-bluemix (but I have no idea if that account name is valid with cloudant.com domain, so just use the cloudant.url as above.

from cloudant-spring.

zedherle avatar zedherle commented on June 15, 2024

for somehow, it does not work. Do you have any sample code/git reference for cloudant db connection so that i can verify. i searched for it and couldn't get. Am i doing app.properties right?

from cloudant-spring.

zedherle avatar zedherle commented on June 15, 2024

however i had to do via Cloudant builder to make that work. btw - does app property has iam key attribute also?

@Bean
    public CloudantClient builder() {
        CloudantClient client = null;
        try {
            client =  ClientBuilder.url(url)
                    .iamApiKey("******")
                    .build();
        } catch (MalformedURLException e) {
            e.printStackTrace();
        }
       return client;
    }

from cloudant-spring.

ricellis avatar ricellis commented on June 15, 2024

Am i doing app.properties right?

Just to be clear the configuration file name is application.properties - I've noticed it called a few other things in this issue (application.prop and app.properties), which I'm assuming are just abbreviations, but I want to make sure we're not missing something simple!

should the property be cloudant.account or cloudant.url ? - i tried both though... (documentation has both as well)

You're using cloudant.url now right? cloudant.account in the documentation example is only valid with that override example shown with an additional @Value("${cloudant.account}") annotated field.

does app property has iam key attribute also?

No, IAM properties have not been added to this lib. You can open another issue to request this feature if you want it.
Currently only Basic auth credentials or Cloudant legacy API keys can be supplied via the cloudant.username and cloudant.password properties. As a workaround you can add a property to your override bean as demonstrated in the README documentation.

Note that if you are using a legacy Cloudant API key it will not be authorized to getAllDbs() - they do not have account level permissions and can only perform actions on specific databases.

from cloudant-spring.

Related Issues (5)

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.