Jhipster login / authentication in mobile app

荒凉一梦 提交于 2021-01-29 04:01:50

问题


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"
]
}
}

回答1:


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.



来源:https://stackoverflow.com/questions/37204503/jhipster-login-authentication-in-mobile-app

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!