File tree 2 files changed +10
-20
lines changed
src/main/scala/com/codacy/client/bitbucket/v2
2 files changed +10
-20
lines changed Original file line number Diff line number Diff line change 1
1
package com .codacy .client .bitbucket .v2
2
2
3
- import play .api .libs .json .{Json , Writes }
4
-
5
3
object Authorization {
6
4
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
15
7
}
16
8
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"
22
11
}
23
12
}
Original file line number Diff line number Diff line change @@ -2,8 +2,7 @@ package com.codacy.client.bitbucket.v2.service
2
2
3
3
import com .codacy .client .bitbucket .client .{BitbucketClient , Request , RequestResponse }
4
4
import 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 }
7
6
8
7
class AuthorizationServices (client : BitbucketClient ) {
9
8
@@ -13,10 +12,12 @@ class AuthorizationServices(client: BitbucketClient) {
13
12
*/
14
13
def refreshAccessToken (
15
14
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"
17
16
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
+ }
19
20
20
- client.postJson (Request (url, classOf [AccessToken ]), values)
21
+ client.postForm (Request (url, classOf [AccessToken ]), values)
21
22
}
22
23
}
You can’t perform that action at this time.
0 commit comments