Coder Social home page Coder Social logo

cloudant-spring's People

Contributors

bardweller avatar dependabot[bot] avatar eiri avatar emlaver avatar katheris avatar mojito317 avatar ricellis avatar tomblench avatar vmatyusgithub avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

cloudant-spring's Issues

getting unauthorised error

Please read these guidelines before opening an issue.

Bug Description

1. Steps to reproduce and the simplest code sample possible to demonstrate the issue

I have put my client credentials in the application.prop like below

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

and then i have autowired as mentioned in the readme of this repository
@Autowired
private CloudantClient client;

through my controller i am calling this method to see if its working
public List getAllDbs() {

    return client.getAllDbs();
}

2. What you expected to happen

I am supposed to be getting right results with list of dbs available.

3. What actually happened

Currently it is throwing me errors like this below,
com.cloudant.client.org.lightcouch.CouchDbException: 401 Unauthorized at https://2a6085c6-394e-4a69-8074-6334f6b0c91a-bluemix.cloudant.com:443/_all_dbs. Error: unauthorized. Reason: one of _all_dbs, _admin, server_admin is required for this request.

But i do have right access. Not sure which part i am doing it wrong.

Environment details

  • Java version including vendor and platform

    1.8

  • Spring framework or boot version

    com.cloudant
    cloudant-spring-boot-starter
    0.0.4

Legacy API key cannot instantiate Database bean

Bug Description

1. Steps to reproduce and the simplest code sample possible to demonstrate the issue

Using a legacy API key (and therefore a database that already exists):

cloudant:
 url: https://example.cloudant.com
 username: mylegacyapikey
 password: passphrase
 db: test

Under the covers this is effectively:

CloudantClient client = ClientBuilder
            .url(config.getUrl())
            .username(config.getUsername())
            .password(config.getPassword());
            .build();
client.database("test", true);

2. What you expected to happen

Expected the Database bean to be instantiated.

3. What actually happened

Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘database’ defined in class path resource [com/ibm/cloudant/spring/boot/CloudantAutoConfiguration.class]: 
Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.cloudant.client.api.Database]: 
Factory method ‘database’ threw exception; nested exception is
 com.cloudant.client.org.lightcouch.CouchDbException: 403 Forbidden. Error: forbidden. Reason: one of _admin, server_admin is required for this request.

Environment details

  • Version(s) that are affected by this issue.

    0.0.3

  • Java version including vendor and platform

    1.8.0_181

  • Spring framework or boot version

    Any

Note this issue is caused because cloudant-spring always calls client.database(..., true) i.e. asking to create the database. Since a legacy API key never has permission to create a database this call is invalid when using an API key resulting in a permissions exception.
Under the hood java-cloudant issues the create call and returns the existing db in cases of a 412 (i.e. the database already exists). It could be argued that java-cloudant should be more lenient and in the case of a 403 check for existence of the database to accommodate a request using a legacy API key, although the call to create is technically invalid.

To resolve this issue requires either:
i) Update java-cloudant to be more lenient and then update the dependency here.
or
ii) Provide a configuration option for controling the create boolean in cloudant-spring

Getting NULL when CloudantClient is Autowired

Bug Description

1. Steps to reproduce and the simplest code sample possible to demonstrate the issue

Below is the connection properties in my application.properties file

cloudant.url=http://something.cloudapp.azure.com:5984
cloudant.username=************
cloudant.password=************

I have then autowired the CloudantClient component in my class as below.

@Autowired
    private CloudantClient client;

    public void sample(){
        log.info(client.getAllDbs().toString());
    }

2. What you expected to happen

Above code is suppose to print the database list or some string.

3. What actually happened

client is null and hence NullPointerException is thrown at the line client.getAllDbs()

Environment details

  • Version(s) that are affected by this issue.
                        <groupId>com.cloudant</groupId>
			<artifactId>cloudant-spring-boot-starter</artifactId>
			<version>0.0.4</version>
  • Java version including vendor and platform

    11 OpenJDK macOS

  • Spring framework or boot version

    Spring boot 2.4.0

Thanks.

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.