File tree Expand file tree Collapse file tree 2 files changed +10
-20
lines changed
src/main/scala/com/codacy/client/bitbucket/v2 Expand file tree Collapse file tree 2 files changed +10
-20
lines changed Original file line number Diff line number Diff line change 11package com .codacy .client .bitbucket .v2
22
3- import play .api .libs .json .{Json , Writes }
4-
53object Authorization {
64
7- sealed trait RefreshCredentials
8-
9- case class RefreshToken (refresh_token : String ) extends RefreshCredentials {
10- val grant_type = " refresh_token"
11- }
12-
13- object RefreshToken {
14- implicit val writer : Writes [RefreshToken ] = Json .writes[RefreshToken ]
5+ sealed trait RefreshCredentials {
6+ val grant_type : String
157 }
168
17- object RefreshCredentials {
18- implicit val writer : Writes [RefreshCredentials ] =
19- Writes [RefreshCredentials ] {
20- case c : RefreshToken => Json .toJson(c)(RefreshToken .writer)
21- }
9+ case class RefreshToken (refresh_token : String ) extends RefreshCredentials {
10+ val grant_type : String = " refresh_token"
2211 }
2312}
Original file line number Diff line number Diff line change @@ -2,8 +2,7 @@ package com.codacy.client.bitbucket.v2.service
22
33import com .codacy .client .bitbucket .client .{BitbucketClient , Request , RequestResponse }
44import com .codacy .client .bitbucket .v2 .AccessToken
5- import com .codacy .client .bitbucket .v2 .Authorization .RefreshCredentials
6- import play .api .libs .json ._
5+ import com .codacy .client .bitbucket .v2 .Authorization .{RefreshCredentials , RefreshToken }
76
87class AuthorizationServices (client : BitbucketClient ) {
98
@@ -13,10 +12,12 @@ class AuthorizationServices(client: BitbucketClient) {
1312 */
1413 def refreshAccessToken (
1514 credentials : RefreshCredentials ): RequestResponse [AccessToken ] = {
16- val url = s " https://bitbucket.org/site/oauth2/access_token "
15+ val url = " https://bitbucket.org/site/oauth2/access_token"
1716
18- val values = Json .toJson[RefreshCredentials ](credentials)
17+ val values = credentials match {
18+ case c : RefreshToken => Map (" grant_type" -> Seq (c.grant_type), " refresh_token" -> Seq (c.refresh_token))
19+ }
1920
20- client.postJson (Request (url, classOf [AccessToken ]), values)
21+ client.postForm (Request (url, classOf [AccessToken ]), values)
2122 }
2223}
You can’t perform that action at this time.
0 commit comments