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

Save access token to DB #12

Closed
isjackwild opened this issue Jul 15, 2020 · 7 comments
Closed

Save access token to DB #12

isjackwild opened this issue Jul 15, 2020 · 7 comments
Assignees
Labels
feature-request New feature or request

Comments

@isjackwild
Copy link

Hey 👋

I've just found your plugin and set it up and it's exactly what I've been looking for! However, I'm running into issues with syncing between environments, using the Craft Project Config file.

Currently I have a local dev environment, a staging environment, and a production environment. These are synced using the Craft Project Config file.

The issue I'm having is:
a) I cannot add localhost to the App OAuth redirects, as it doesn't allow any non-HTTPS URI's
b) If I authorise Craftagram on Staging or Production, it all works fine, but when I then sync again, the long access token gets removed
c) If I were to set up a cron job to renew the access token on production, as outlined in the docs, this would presumably cause the project config on production to be different from other environments, and would also be overwritten the next time Craft was synced.

I was wondering if this is something which has been considered and if there's a work-around for, as unfortunately if it's not compatible it will mean I'm not able to use the Plugin. It's always such a pain working with the Instagram API, why do they make it so hard! 😂

@isjackwild
Copy link
Author

Just had a thought... could this be achieved simply by storing the long access token in a craftagram specific config table in the database (an approach used by some other plugins I've seen), rather than being stored in the project config?

@jsmrtn
Copy link
Owner

jsmrtn commented Jul 16, 2020

I cannot add localhost to the App OAuth redirects, as it doesn't allow any non-HTTPS URI's

Is this an instagram restriction or a restriction in our plugin? I don't think we have put in any checks on whether the redirect_uri needs to be HTTP or HTTPS, but I could be wrong.

I agree regarding storing the token in the database. I hadn't considered project configs would get out of sync!

@jsmrtn jsmrtn changed the title Issues with syncing between environments and project config Put long-access token into DB and not as a setting Jul 16, 2020
@jsmrtn jsmrtn self-assigned this Jul 16, 2020
@jsmrtn jsmrtn added the feature-request New feature or request label Jul 16, 2020
@isjackwild
Copy link
Author

The non-HTTPS thing is an instagram restriction. It could probably be worked around using ngrok now I think of it, although might not need to if you just don't bother setting it up on production / staging environments.

The project syncing thing is something I've come across with a couple of other plugins also, it's an awesome feature usually, but sometimes plugin settings can end up overwriting themselves, as everything will be synced with your development project.yml. Another thing to consider though is how to connect / install the instagram on production environments which may have allowAdminChanges: false — as you can't access or update settings section or plugins if this is set. Some other plugins I've seen have a work around where they add in a new item to the main craft menu (left hand sidebar) where you can do the instagram authorisation action.

@WHITE-developer
Copy link

Having the same problem with the multi environment.
Another additional thing, it would be cool to store the app keys in .env variables so they don't end up in git history.

This was referenced Jul 16, 2020
@jsmrtn jsmrtn changed the title Put long-access token into DB and not as a setting Save access token to DB Jul 16, 2020
@jsmrtn
Copy link
Owner

jsmrtn commented Jul 22, 2020

@isjackwild 1.2.0 is available and will store the long-access token in the database. It also has a CP section available.

@jsmrtn jsmrtn closed this as completed Jul 22, 2020
@WHITE-developer
Copy link

Hey @joshua-martin thanks for the updates!
Only one thing small thing: when using the authorize button with allowAdminChanges = false, it still redirects to the settings page which is showing the "Administrative changes are disallowed in this environment." 😄
It saves perfectly, only the redirect goes wrong.

@jsmrtn
Copy link
Owner

jsmrtn commented Jul 27, 2020

@WHITE-developer 1.2.1

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants