markgravity / flutter-survey

3 stars 0 forks source link

[17] [Backend] Add Auth service #45

Closed markgravity closed 3 years ago

markgravity commented 3 years ago

https://github.com/markgravity/flutter-survey/issues/17

What happened

We need a service to handle API calls relate to authentication, store auth information to local storage

Proof Of Work

login

flutter: *** Request ***
flutter: uri: https://nimble-survey-web-staging.herokuapp.com/api/v1/oauth/token
flutter: method: POST
flutter: responseType: ResponseType.json
flutter: followRedirects: true
flutter: connectTimeout: 0
flutter: sendTimeout: 0
flutter: receiveTimeout: 0
flutter: receiveDataWhenStatusError: true
flutter: extra: {}
flutter: headers:
flutter:  authorization: Bearer i6LRD9fqvn6UGY_lFhJG2uIJktMVd8AW7T8BEiZkRRk
flutter:  content-type: application/json; charset=utf-8
flutter: data:
flutter: {email: dev@nimblehq.co, password: 12345678, client_id: z9iUamZLvRgtVVtRJ8UqItg2vmncGyEi30p1eWEddnA, client_secret: 1vqRNMxq-Yx83A61GNjLb17qxCGKxHDb8EmB3MKdxqA, grant_type: password}

logout

flutter: *** Request ***
flutter: uri: https://nimble-survey-web-staging.herokuapp.com/api/v1/oauth/revoke
flutter: method: POST
flutter: responseType: ResponseType.json
flutter: followRedirects: true
flutter: connectTimeout: 0
flutter: sendTimeout: 0
flutter: receiveTimeout: 0
flutter: receiveDataWhenStatusError: true
flutter: extra: {}
flutter: headers:
flutter:  content-type: application/json; charset=utf-8
flutter: data:
flutter: null
flutter:
flutter: *** Request ***
flutter: uri: https://nimble-survey-web-staging.herokuapp.com/api/v1/me
flutter: method: GET
flutter: responseType: ResponseType.json
flutter: followRedirects: true
flutter: connectTimeout: 0
flutter: sendTimeout: 0
flutter: receiveTimeout: 0
flutter: receiveDataWhenStatusError: true
flutter: extra: {}
flutter: headers:
flutter:  authorization: Bearer PD0Reopv5f5phuWzalDxZ-_1MUnEwZdRkhRs-T9Je9E
flutter: data:
flutter: null
flutter:
flutter: *** DioError ***:
flutter: uri: https://nimble-survey-web-staging.herokuapp.com/api/v1/oauth/revoke
flutter: DioError [DioErrorType.response]: Http status error [403]
#0      DioMixin.assureDioError (package:dio/src/dio_mixin.dart:819:20)
#1      DioMixin._dispatchRequest (package:dio/src/dio_mixin.dart:678:13)
<asynchronous suspension>
#2      DioMixin.fetch.<anonymous closure>.<anonymous closure> (package:dio/src/dio_mixin.dart)
<asynchronous suspension>
flutter: uri: https://nimble-survey-web-staging.herokuapp.com/api/v1/oauth/revoke
flutter: statusCode: 403
flutter: headers:
flutter:  connection: keep-alive
flutter:  cache-control: no-cache
flutter:  transfer-encoding: chunked
flutter:  date: Wed, 05 May 2021 16:59:33 GMT
flutter:  vary: Accept-Encoding, Origin
flutter:  content-encoding: gzip
flutter:  strict-transport-security: max-age=31536000; includeSubDomains
flutter:  referrer-policy: strict-origin-when-cross-origin
flutter:  x-permitted-cross-domain-policies: none
flutter:  content-type: application/json; charset=utf-8
flutter:  x-xss-protection: 1; mode=block
flutter:  server: Cowboy
flutter:  x-request-id: a1301572-8534-4ec1-8fc4-ed1d79164b28
flutter:  x-download-options: noopen
flutter:  x-runtime: 0.009951
flutter:  via: 1.1 vegur
flutter:  x-frame-options: SAMEORIGIN
flutter:  x-content-type-options: nosniff
flutter: Response Text:
flutter: {"errors":[{"detail":"You are not authorized to revoke this token","code":"unauthorized_client"}]}
sleepylee commented 3 years ago

please update your POW to the PR as per our normal workflow, PR template. 🙇