投稿時間:2022-11-27 18:07:34 RSSフィード2022-11-27 18:00 分まとめ(9件)

カテゴリー等 サイト名等 記事タイトル・トレンドワード等 リンクURL 頻出ワード・要約等/検索ボリューム 登録日
python Pythonタグが付けられた新着投稿 - Qiita HuggingFace(BERT)を便利なTrainerを使用して分類する https://qiita.com/ku_a_i/items/c7792be568615f451b98 huggingface 2022-11-27 17:51:40
python Pythonタグが付けられた新着投稿 - Qiita 傾斜量の算出方法(その2) https://qiita.com/KouichiGodai/items/048aba86ffb7734498b8 計算 2022-11-27 17:24:13
golang Goタグが付けられた新着投稿 - Qiita 【個人用】Go言語チートシート https://qiita.com/Soleiyu/items/50148f04cc0d18c771e7 packagemainf 2022-11-27 17:57:29
海外TECH DEV Community 4 Steps to Create Google Authentication API in Node.js https://dev.to/shreyvijayvargiya/4-steps-to-create-google-authentication-api-in-nodejs-41d3 Steps to Create Google Authentication API in Node jsUnder the HoodThe story began when my friend asked me about integrating Passport js and JSON Web Token JWT together He wanted to create an API or endpoint providing Google authentication using Passport js with Express and JWT So I thought why not write a story to help many developers in the market so that you don t have to read StackOverflow or the documentation Getting StartedBefore we start remember that Google authentication or Facebook or Github requires a client ID and client secret which you can grab from their corresponding developer console or dashboard But overall all third party OAuth works on the same principle of client id and client secret In just four steps we will create a Google authentication API with Passport js and JWT Overall FlowThis will be the overall flow ーInitialize the passport by adding configuration to the strategy instance Create a route v auth google which will begin the google authentication and open the google email selection modal for users Basically redirect to the google login page Add passport google authentication as a middleware for v auth google the route being middleware we will call the passport authentication method and provide our client id and the secret to the middleware function Once the passport verify callback is called successfully it will return the profile containing the user email and username Using the user profile details produced from passport middleware create a JWT token and store the user details in the database with a ticket if you want Lastly handle the callback URL you mentioned in the google developer console in the custom server This callback URL will handle the redirection or passing token to the client in response Initializing Passport jsInitialising is quite simple as it only needs steps Add required Passport js npm packages such as passport amp passport google oauthPass the auth strategy and callback to the passport use method Auth strategy added in the params need clientId clientSecret amp callbackURLSerialize and Deserialize the user send by passport using its corresponding methods Lastly add this confirmed passport instance and initialise them using express middleware methods Inside the middlewares passport directory add the following code const passport require passport const GoogleStrategy require passport google oauth Strategy passport use new GoogleStrategy callbackURL http localhost auth google callback clientID nklfqlrfdhoklbupvffggh apps googleusercontent com clientSecret GOCSPX uvWTdTmnEQrBGddufBosyI accessToken refreshToken profile done gt console log profile profile done null user passport serializeUser user done gt if user return done null user else return done null false passport deserializeUser id done gt if user return done null user else return done null false module exports passport Lastly initialise the exported passport using the express middleware method by adding the following code const passport require middlewares passportMiddleware server use passport initialize Let me explain what we re doing here ーWe pass the auth strategy to the passport use method and since we are using google authentication clientId and clientSecret and callbackURL are required Then we have just defined the callback function invoked when everything is successful from the passport end Lastly we have just added serialised and deserialised methodThen inside the server js file we initialise that exported passport method using the express use method Note ーPlease do not remove serialise and deserialise methods as we need them to read the logged in user data Creating a route for Google loginIt s a primary GET route We don t have to send anything from the client side The agenda of this route will be to invoke passport middleware const passport require passport router get v auth google passport authenticate google session false scope profile email We have also provided the scope and authentication strategy for the passport authentication method Saving User Profile and Creating JWT tokenHere comes the climax of the story once the passport middleware gets invoked and we get the user profile details we have to deal with JSON web token and our database system It is totally up to your choice on what to do with tickets some developers prefer to store tokens in the database and some do not I always send the key to the cookie once the user logs in successfully Inside Passport js when the callback for the passport use method is called it will return the user profile we have already consoled This is where we will create our JWT token and if you want you can store the user details in the database const passport require passport const GoogleStrategy require passport google oauth Strategy const jwt require jsonwebtoken passport use new GoogleStrategy callbackURL http localhost auth google callback clientID nklfqlrfdhoklbupvffggh apps googleusercontent com clientSecret GOCSPX uvWTdTmnEQrBGddufBosyI accessToken refreshToken profile done gt Check if user with same email or id exists in DB if not create one and save in DB const token jwt sign email profile emails process env JWTSecretKey expiresIn d const user email profile emails username profile username id profile id profileUrl profile profileUrl token Now token and user are ready store them in DB done null user passport serializeUser user done gt if user return done null user else return done null false passport deserializeUser id done gt if user return done null user else return done null false module exports passport JSON web token introductionHandling Callback URLThe last part is to handle the callback redirect URL If you remember we have added a callback URL in the google developer console but that URL doesn t exist in our custom server In this current case once the token is created the user has logged in and the user will be redirected to the redirect callback URL Now it s our job as developers to define the actual method or route to which the logged in user should be thrown const passport require passport router get auth google callback passport authenticate google failureRedirect req res gt res cookie authToken req user token res redirect I am sending the token in the cookie to the user and redirecting him when they have logged in successfully This callback URL will only get called when everything went as planned and the user has logged in successfully using google authentication On the client side grab the token from the cookie and verify it using another API to confirm its authenticity and confirm that the user is logged in successfully Saving tokens in cookies has its pros and makes it easy to handle user sessions across multiple tabs and devices ConclusionI comprise the story in steps but it took some time for me to grasp the idea initially especially if you are new to this Node and Passport world That is why I tried to finish the entire story in steps so that you can remember those four steps simultaneously Until next time have a good day people Keep developingShreyiHateReading 2022-11-27 08:52:07
海外TECH DEV Community How to Delete Local and Remote Git Branches https://dev.to/refine/how-to-delete-local-and-remote-git-branches-311f How to Delete Local and Remote Git BranchesAuthor Muhammad Khabbab IntroductionBranches are kind of blocks in a repository where we write new features fix bugs etc For example if three developers are working on a project they can create their own branches and work on them as the branches are isolated so everyone can work in their branch A branch can be Local only on your local machine Remote it is on a remote location for example in the GitHub repoActually there is a third type of branch which is the reference to the remote branches During the cleanup these branches should be cleaned up too Today we will discuss various scenarios related to branch deletion We will show you how to delete local and remote branches on GitHub We will also go through some common errors while deleting a branch For this article we assume you have installed GIT and you have the access rights to delete a branch Let s start with the need to delete a branch Steps we ll cover Why you might need to remove a branchDeleting a GIT local branchDeleting a Git remote branchDeleting a branch with merged changesDeleting a git branch with unmerged changesWhat are tracking branches and how to delete themHow to delete a branch on Github using web consoleFrequently asked questionsI am unable to delete my branchI deleted a branch by mistake can I recover it How to automatically delete a branch when it is merge back into masterI am getting an error when I delete a branch having the same name as a tag Why you might need to remove a branchYou need to ensure that your Git repository is not a mess of outdated and old branches that are not being worked on anymore You should perform periodic cleanup of the branches where you would either remove the old branches or you would merge them into the master Your code repository should be neat tidy and easy to navigate Building a side project Meet the headless React based solution to build sleek CRUD applications refine expertly combines cutting edge technologies under a robust architecture so you don t have to spend time researching and evaluating solutions Try refine to rapidly build your next CRUD project whether it s an admin panel dashboard internal tool or storefront Deleting a GIT local branchPlease note that deleting a branch locally will not delete the remote branch Here is the command to delete branch locally git branch d branch name The below command will also perform the same function just a minor syntax difference git branch delete lt branch gt Note that the d option is an abbreviation for delete which only removes the branch if it is fully merged in its parent branch If you have unmerged changes then it will not remove the branch and you will get an error You will need to forcibly remove the branch if you want to delete the branch irrespective of the merge status You can use the below command to remove the local branch forcibly git branch D lt branchName gt Another point to remember is the rebasing merging progress If your branch is in rebasing merging process You will see an error Rebase Merge in progress and you won t be able to delete your branch You can forcibly delete if you want to or you can solve the rebasing merging before trying again Deleting a Git remote branchTo delete a branch from the remote repository type git push origin d branch name In the above example the remote branch dev testing is deleted Both the below commands delete the remote branch you can use whichever is more intuitive to you git push lt remote name gt delete lt branch name gt The following command is appropriate if you are on a version of Git older than git push lt remote name gt lt branch name gt Note that executing git push origin delete will delete your remote branch only Note that the branch name is not mentioned at the end of the command However if you put the branch name at the end it will delete and push it to remote simultaneously Deleting a branch with merged changesWhen we are deleting a branch having merged changes we delete it by using small d like below git branch d lt BranchName gt Deleting a git branch with unmerged changesWhen we are deleting a branch having unmerged changes then we will need to use the capital D to force the deletion like below git branch D lt branchName gt Another version of the same command is as below git branch delete force lt branch name gt It will also remove the branch forcibly even if there are unmerged changes in the branch What are tracking branches and how to delete themWhen we check out a local branch from a remote branch it automatically creates what is called a tracking branch These are local branches that have a direct association with a remote branch It means it exists on our local machine cache but not on the remote repository If you have deleted a remote branch using the command git push origin lt branchname gt its references still exist in local code repo of your team members Now you need to delete the local references too git remote prune origin deletes the refs to the branches that don t exist on the remote Another version of the same command is git fetch lt remote gt pruneThis will delete all the obsolete remote tracking branches A shorter version of the command is below git fetch lt remote gt pTo delete a particular local remote tracking branch you can use following command git branch delete remotes lt remote gt lt branch gt A shorted version of the command is git branch dr lt remote gt lt branch gt Note that if you delete a remote branch X from the command line using git push then it will also remove the local remote tracking branch origin X so there is no need to prune the obsolete remote tracking branch with git fetch prune or git fetch p To confirm if the remote tracking branch was delete or not you can run the following commandgit branch remotesAnd the shorter version is git branch r How to delete a branch on Github using web console Navigate to the main page of the repository Above the list of files click branches Navigate to the branch you want to delete then click delete icon Frequently asked questions I am unable to delete my branchSolution You cannot delete a branch you are already on You must first switch to another branch and then delete the required branch See the below example In the above example we switched to another branch named dev arsam and then we were able to delete the test branch successfully I deleted a branch by mistake can I recover it Solution Yes you should use git reflog command and find the SHA for the commit at the tip of your deleted branch then just git checkout sha And once you re at that commit you can just git branch branchname lt SHA gt to recreate the branch from there The git reflog command is used to record updates made to the tip of branches It allows to return to commits After rewriting history the reflog includes a history of previous branch commits and makes it possible to go back to a particular state if needed The below snapshot provides an example where a branch named dev arsam will be recovered How to automatically delete a branch when it is merge back into masterTo avoid dangling branches you can set up the configuration so that your branch will be automatically deleted as soon as it is merged into its parent branch e g Master branchOn GitHub com go to the home page of the repository Under your repository name click Settings Under Pull Requests select or unselect Automatically delete head branches I am getting an error when I delete a branch having the same name as a tagYou might get an error if you try to delete a branch having the same name as the tag You will see an error similar to this branch or tag name matches more than one If you want to specify the deletion of branches and not tag try the below command git push origin refs heads branch nameSimilarly if you want to specify the deletion of tags and not branch then use below command git push origin refs tags tag name ConclusionIn this article we learned about the different ways to delete a branch in Git also answered frequently asked questions related to deleting a branch in Git 2022-11-27 08:14:10
海外ニュース Japan Times latest articles Kishida Cabinet support rate plunges to lowest since launch https://www.japantimes.co.jp/news/2022/11/27/national/politics-diplomacy/kishida-support-rate-lowest-poll/ Kishida Cabinet support rate plunges to lowest since launchThe PM s disapproval rating rose to exceeding for the first time since he took office in October last year after three ministers were 2022-11-27 17:48:56
ニュース BBC News - Home Covid protests widen in China after 10 killed in flats fire https://www.bbc.co.uk/news/world-asia-63771109?at_medium=RSS&at_campaign=KARANGA jinping 2022-11-27 08:17:06
海外TECH reddit ハードオフ行ったら熊の手みたいなの有ったんだけど https://www.reddit.com/r/lowlevelaware/comments/z5vm2i/ハードオフ行ったら熊の手みたいなの有ったんだけど/ wlevelawarelinkcomments 2022-11-27 08:15:33
海外TECH reddit 中南大学国防生公寓 https://www.reddit.com/r/real_China_irl/comments/z5vilx/中南大学国防生公寓/ rrealchinairllinkcomments 2022-11-27 08:09:45

コメント

このブログの人気の投稿

投稿時間:2021-06-17 22:08:45 RSSフィード2021-06-17 22:00 分まとめ(2089件)

投稿時間:2021-06-20 02:06:12 RSSフィード2021-06-20 02:00 分まとめ(3871件)

投稿時間:2021-06-17 05:05:34 RSSフィード2021-06-17 05:00 分まとめ(1274件)