简体   繁体   中英

Jhipster login / authentication in mobile app

How to get a session cookie and the CSRF token from jhipster then use them in your calls to the API from mobile app. I am using HTTP session authentication.

JHipster configuration, a .yo-rc.json file generated in the root folder

{
"generator-jhipster": {
"jhipsterVersion": "3.0.0",
"baseName": "vconnect",
"packageName": "com.zenfact.vconnect",
"packageFolder": "com/zenfact/vconnect",
"serverPort": "8080",
"authenticationType": "session",
"hibernateCache": "ehcache",
"clusteredHttpSession": "no",
"websocket": "no",
"databaseType": "sql",
"devDatabaseType": "postgresql",
"prodDatabaseType": "postgresql",
"searchEngine": "elasticsearch",
"buildTool": "maven",
"enableSocialSignIn": false,
"rememberMeKey": "559bbe3167552d040ba24d16506d389a7ba851c3",
"useSass": false,
"applicationType": "monolith",
"testFrameworks": [
"gatling"
],
"enableTranslation": true,
"nativeLanguage": "en",
"languages": [
"en",
"zh-cn",
"fr",
"hi",
"ja"
]
}
}

I don't have any mobile experience but cookies are known to be difficult with mobile. I'd recommend using jhipster's Oauth2 option instead. Then you just need to get an access token and add the header "Authorization: Bearer " to your api calls.

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