简体   繁体   中英

PhP - Withings Authentication Implementation

I'm making a web-application which run under Laravel 5, and I need to incorporate Withings user's Datas. I read the API's doc, but I don't understand it very well.

What are the authentication steps, and the order? Have you any example in aim to help me?

Withings seems to use OAuth1, you can find an authentication flow of the standard, which help to see the global picture, at https://oauth.net/core/1.0/#anchor9 : OAuth认证流程

Their API is described at http://oauth.withings.com/en/api/oauthguide and also https://developer.health.nokia.com/api (with a request tester), but you probably already got that.

There's some libraries (with the composer name) you might find interesting to use (or read to help with comprehension):

Setting Up the Environment

I am going to assume you are starting off with a fresh Laravel 5 installation, but you can skip any of these steps if you have already done them. First off, you are going to set some environment variables in the .env file at the root of your project. Basically, these have to do with the database configuration

APP_ENV=local
APP_DEBUG=true
APP_KEY=8wfDvMTvfXWHuYE483uXF11fvX8Qi8gC

DB_HOST=localhost
DB_DATABASE=laravel_5_authentication
DB_USERNAME=root
DB_PASSWORD=root

CACHE_DRIVER=file
SESSION_DRIVER=file

Notice the APP_ENV, DB_HOST, DB_DATABASE, DB_USERNAME, and DB_PASSWORD variables. The APP_ENV variable tells Laravel which environment we wish to run our web application in. The rest of the database variable names are pretty obvious.

This is all you need to do to configure the database connection. But how does Laravel make use of these variables? Let's examine the config/database.php file. You will notice the use of the env() function. For example, env('DB_HOST', 'localhost'). Laravel 5 uses this function to capture variables from the $_ENV and $_SERVER global arrays, which are automatically populated with the variables you define in the .env file.

there is whole tutorial on this have a look http://code.tutsplus.com/tutorials/using-laravel-5s-authentication-facade--cms-23461

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM