Skip to content
This repository has been archived by the owner on Jul 30, 2023. It is now read-only.

Commit

Permalink
Merge pull request #56 from hero-matsumoto/apps_post_encode
Browse files Browse the repository at this point in the history
userNameおよびpasswordはURLエンコードが必要です
  • Loading branch information
sys1yagi authored Nov 1, 2017
2 parents 5ae30f6 + be67525 commit 57d6fc8
Showing 1 changed file with 10 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.sys1yagi.mastodon4j.api.method

import com.sys1yagi.mastodon4j.MastodonClient
import com.sys1yagi.mastodon4j.MastodonRequest
import com.sys1yagi.mastodon4j.Parameter
import com.sys1yagi.mastodon4j.api.Scope
import com.sys1yagi.mastodon4j.api.entity.auth.AccessToken
import com.sys1yagi.mastodon4j.api.entity.auth.AppRegistration
Expand Down Expand Up @@ -94,14 +95,15 @@ class Apps(private val client: MastodonClient) {
password: String
): MastodonRequest<AccessToken> {
val url = "https://${client.getInstanceName()}/oauth/token"
val parameters = listOf(
"client_id=$clientId",
"client_secret=$clientSecret",
"scope=$scope",
"username=$userName",
"password=$password",
"grant_type=password"
).joinToString(separator = "&")
val parameters = Parameter().apply {
append("client_id", clientId)
append("client_secret", clientSecret)
append("scope", scope.toString())
append("username", userName)
append("password", password)
append("grant_type", "password")
}.build()

return MastodonRequest(
{
client.postUrl(url,
Expand Down

0 comments on commit 57d6fc8

Please sign in to comment.