kakao / kakao_flutter_sdk

Flutter SDK for Kakao Open API
Apache License 2.0
193 stars 70 forks source link

How to get token in flutter web ? #9

Closed bakboem closed 4 years ago

bakboem commented 4 years ago

return code only ..

CoderSpinoza commented 4 years ago

You can pass the authorization code to AuthApi class. Below is a sample code.

void loginButtonClicked() async {
  try {
    String authCode = await AuthCodeClient.instance.request();
    AccessToken token = await AuthApi.instance.issueAccessToken(authCode);
    AccessTokenStore.instance.toCache(token);
  } catch (e) {
    // some error happened during the course of user login... deal with it.
  }
}
bakboem commented 4 years ago

okey.. i'll try

web also needs to added ?

this is error info. error on issuing access token: {error: misconfigured, error_description: invalid android_key_hash or ios_bundle_id or web_site_url}

CoderSpinoza commented 4 years ago

Oh, sorry did not realize you are working on flutter web. As of 0.3.2, this SDK does not support Flutter web yet. There are two problems.

  1. SDK itself will not be able to get authorization code because it currently lacks platform-specific code for getting authorization code.
  2. Kakao API server did not allow CORS and any request in the browser will be blocked.

The first issue could be addressed with the next release (It's already pushed , https://github.com/CoderSpinoza/kakao_flutter_sdk/commit/8cd4f29b0c078e9744e8c9a8beaf07248eef7856 contains the relevant code) but the second issue should be addressed by Kakao API team itself. Therefore, it might take a little longer.

What you can do for now is get token with the next release (0.4.0) and pass that token to server and call on the server side. If you need this feature, then I will hurry with the next release.

bakboem commented 4 years ago

thank you !~ I will wait patiently for the next update ^^ good luck, man!

CoderSpinoza commented 4 years ago

Haha I will update you when it's done. I would appreciate it if you could star this repo :)

bakboem commented 4 years ago

I'm sorry for the late reply.. this is good library !~ thank you!

bakboem commented 4 years ago

Hi Kang~ How are you doing? I'm waiting for you to update hah

CoderSpinoza commented 4 years ago
  1. Kakao API server did not allow CORS and any request in the browser will be blocked.

Number 2 from above list is still not addressed. I am sorry for the delay.

I have created a separate issue #10 for web support so you can f/u there. I will close this issue.

Thanks for your interest in Kakao API and Kakao Flutter SDK.