Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Android CODE Auth Flow #121

Merged
merged 4 commits into from
Apr 15, 2021
Merged

Android CODE Auth Flow #121

merged 4 commits into from
Apr 15, 2021

Conversation

cjam
Copy link
Owner

@cjam cjam commented Apr 2, 2021

This PR just addresses all of the comments from the original PR #68.

Created a new branch so I could do the code changes directly.

uptotec and others added 4 commits April 2, 2021 07:29
- some cleanup in java auth module
- update to babel config for example
- update to ApiConfig to include authType
- update to spotifySession to include code
- Provide button for new auth type
@cjam cjam mentioned this pull request Apr 2, 2021
@@ -48,15 +48,19 @@ public void authorize(ReadableMap config, Promise promise) {
String redirectUri = mConfig.getString("redirectURL");
Boolean showDialog = mConfig.getBoolean("showDialog");
String[] scopes = convertScopes(mConfig);
AuthorizationResponse.Type responseType = mConfig.hasKey("authType") ?
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@MrBuggySan Thanks for the idea for cleaning up this code.

* @type {string}
* @memberof SpotifySession
*/
code?: string;
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@reteps would you have a quick gander at the changes? Also, I've updated the example app.. but I'm currently using the CODE / TOKEN interchangeably. What is the expected behavior of the CODE type?

You were mentioning being able to skip the auth screen. When I use the code type it still does bring up the spinner for a moment. It seems that either the accessToken or the code can be used to connect to the spotify remote. So I think I can probably remove this from the API and just return either the code or the token in the accessToken property.

Anyways, I can't find any docs on the CODE option so I'm not sure what the expectation is.

Copy link

@theshadowagent theshadowagent Jan 12, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a bad coding practice. CODE is an auth flow for different needs (e.g. when you need to refresh tokens on your server), and inserting both code and accessToken in one accessToken property made me think this feature is actually not working / not supported. After an hour of research, I luckily found this PR. The only way I could make sure the CODE flow is working is by comparing the length of the accessToken field (code appears to be longer, I had an example).

Grateful for your work on the library, but please don't use one field for two completely different things.

@@ -146,12 +148,13 @@ class AppContextProvider extends React.Component<{}, AppContextState> {
}));

// Initialize the session
const { accessToken } = await auth.authorize(config);
const { accessToken, code } = await auth.authorize(config);
const token = code || accessToken;
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@reteps Both code and accessToken seem to work to connect to the remote, but perhaps Im misunderstanding the purpose of each.

@cjam
Copy link
Owner Author

cjam commented Apr 2, 2021

Thanks @uptotec for the original PR.

@cjam cjam merged commit 7c2edc5 into master Apr 15, 2021
@cjam cjam deleted the pr68-refreshable-tokens branch April 15, 2021 14:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants