GithubHelp home page GithubHelp logo

sozenarede / spring-social-garmin Goto Github PK

View Code? Open in Web Editor NEW

This project forked from tomwetjens/spring-social-garmin

0.0 0.0 0.0 35 KB

Connect your Spring application with Garmin Connect API.

License: MIT License

Java 100.00%

spring-social-garmin's Introduction

spring-social-garmin

Connect your Spring application with Garmin Connect API.

Getting Started

Garmin Connect offers an API with OAuth 2.0 support, but is closed and paid.

This Spring Social integration simply logs the user into the Garmin Connect website with username and password and then calls services that are also called from the Garmin Connect web application.

Therefore, instead of an access token, the user name and password of the user must be stored with the connection. Make sure to use a ConnectionRepository implementation that stores the secret encrypted.

Add Garmin support to your Spring Social configuration:

@Configuration
@EnableSocial
public class SocialConfig extends SocialConfigurerAdapter {

    public void addConnectionFactories(ConnectionFactoryConfigurer connectionFactoryConfigurer, Environment environment) {
        // ...

        connectionFactoryConfigurer.addConnectionFactory(new GarminConnectConnectionFactory());
    }
}

Connect

When using Spring Social, you normally add the ConnectController as a bean to your configuration. Because Garmin Connect requires a different way of connecting, you have to also add the GarminConnectController as a bean.

    @Bean
    @Autowired
    public GarminConnectController garminConnectController(ConnectionFactoryLocator connectionFactoryLocator, ConnectionRepository connectionRepository) {
        return new GarminConnectController(connectionFactoryLocator, connectionRepository);
    }

See http://docs.spring.io/spring-social/docs/1.0.3.RELEASE/reference/html/connecting.html.

To connect a user to Garmin Connect, do a request to the GarminConnectController:

POST /garmin/connect
Content-Type: application/x-www-form-urlencoded

username=<username>&password=<password>

This will return a 200 OK if the connection was successful, or a 4xx if the authentication failed or an unexpected error occurred.

Use the standard Spring Social ConnectController to view and manage connections.

Sign in

When using Spring Social, you normally add the ProviderSignInController as a bean to your configuration. Because Garmin Connect requires a different way of sign in, you have to also add the GarminSignInController as a bean.

    @Bean
    @Autowired
    public GarminSigninController garminSigninController(ConnectionFactoryLocator connectionFactoryLocator, UsersConnectionRepository usersConnectionRepository, SignInAdapter signInAdapter) {
        return new GarminSigninController(connectionFactoryLocator, usersConnectionRepository, signInAdapter);
    }

You also need to set a SignInAdapter as described in http://docs.spring.io/spring-social/docs/1.0.3.RELEASE/reference/html/signin.html.

To sign in a user with Garmin Connect, do a request to the GarminSignInController:

POST /garmin/signin
Content-Type: application/x-www-form-urlencoded

username=<username>&password=<password>

This will return a 200 OK if the sign in was successful, or a 4xx if the authentication failed or an unexpected error occurred.

Currently it is expected that you provide a login form or send the request asynchronously.

spring-social-garmin's People

Contributors

tomwetjens avatar

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.