I just started to learn Swift recently and I implemented the sample code that Google gives us to create a calendar. However, I would also like to know how to signout of an account to switch to another calendar but I can't seem to figure it out. Could someone give me some pointers?
Thanks for your help in advance! :-)
Tim
Google docs has a revoking a token guide for OAuth 2.0.
You can use request using HTTP/REST:
curl https://accounts.google.com/o/oauth2/revoke?token={token}
If you're not familiar with HTTP request in Swift, try the following guides in this thread using NSURLConnection.
let url = NSURL(string: "https://accounts.google.com/o/oauth2/revoke?token={token}")
let task = NSURLSession.sharedSession().dataTaskWithURL(url!) {(data, response, error) in
print(NSString(data: data!, encoding: NSUTF8StringEncoding))
}
task.resume()
Related
I got a task to perform google authentication. My task is like i should create a sign in with google button and after clicking it the authentication process should start and shows my details in the next view. I wrote code like this.
let url = URL(string: "https://accounts.google.com/o/oauth2/v2/auth?scope=email%20profile&response_type=code&state=security_token%3D138r5719ru3e1%26url%3Dhttps://oauth2.example.com/token&redirect_uri=someuri:/oauth2redirect&client_id=myclient id")!
and for the button i wrote function like
#IBAction func googleSignIn(_ sender: Any) {
UIApplication.shared.open(url, options: [:], completionHandler: nil)
}
I dont know how to get to get the authorization code so that i can send it back to get the access token. I sould not follow any steps provided in google to integrate my with google sign in also i should not use any pods. Anyone worked on it? please help me.
I'm currently trying to implement GitHub Authentication via Firebase in an iOS app.
I've read through the docs and figured out what I have to do. I'm having trouble though, in implementing the communication between my app and the WebView where I authorize the application to get user's data. I currently have this code:
let url = urlComponents.url! // https://github.com/login/oauth/authorize + scope
// Not quite sure if I should use open(_:options:completionHandler:) to handle this operation.
guard UIApplication.shared.canOpenURL(url) else {
return
}
UIApplication.shared.open(url, options: [:], completionHandler: nil)
What this code does is bring the user to the browser with the GitHub authorization screen, type the password and then a blank screen shows up. Inspecting the URL in this blank screen, I've found out that it contains the parameter it should have, but I'm not quite sure how to pass this parameter to my code so I can proceed with the authentication.
Firebase doc says I should implement a Custom URL scheme to handle the OAuth callback, but I'm not sure how to do it.
Solved, solution was to edit GitHub's Authorization callback URL to have my custom URL scheme and then proceed through the documentation flow.
I'm trying to implement Steam Authentication via OpenID for iOS using this framework. I already translated the demo to Swift 3 and made it work with Google. Now I'm trying to get it to work with Steam and I don't know where to find some of its configuration. To make the app work with Google I use this information:
let kClientID = "xxxxx.apps.googleusercontent.com"
let KRedirectURI = URL(string: "com.googleusercontent.apps.xxxxxx:/oauthredirect")
let kIssuer = URL(string: "https://accounts.google.com")
I've being looking in their dev wiki but so far I could just find how to get the API key. Would you have this information? It is my first contact with OpenID and I'm a bit lost.
Thanks for any help
I read the below link and now I understood that I need to make an api call to fetch the contacts. As I am new to Swift3 could someone guide me how to do this. I read somewhere that Almofire and Swifty json would help and I also read GData also will help. I am little confused. Please guide me.
Google Contacts API
You might want to try Google Sign-In for iOS, get users into your apps quickly and securely, using a registration system they already use and trust—their Google account. This Google Sign-in videos - series #1, series #2 and series #3 will help you understand the implementation of Google SignIn in iOS, how do you use Google Sign in on iOS with another service like Google Drive? and more.
Here are some tutorials and reference that can help:
Integrate Google Signin SDK In iOS Application Using Swift
How to Integrate Google Sign In into Your iOS Apps
Requesting additional scopes after sign-in
Invite friends from Gmail (This tutorial use a gmail contact scope rather than the google plus contacts) PS. not an iOS tutorial
Lastly here are some related SO question for refrence - How to fetch gmail Contacts in iOS application using google contacts api? and Get Google contacts using API on iOS
Hope this helps.
I was actually stuck on this too and couldn't find a solution but I ended up figuring it out. You first need to authenticate with Google Sign In and then pass the accessToken into this endpoint:
let urlString = ("https://www.google.com/m8/feeds/contacts/default/full?alt=json&max-results=5000&access_token=\(GIDSignIn.sharedInstance().currentUser.authentication.accessToken!)")
guard let url = URL(string: urlString) else { return }
URLSession.shared.dataTask(with: url, completionHandler: {
(data, response, error) in
if(error != nil){
print("error")
}else{
do{
let json = try JSONSerialization.jsonObject(with: data!, options:[]) as! [String : AnyObject]
//parse JSON
}catch let error as NSError{
print(error)
}
}
}).resume()
Can i fetch details of unfollower of Instagram user using instagram api?
If it's possible then how can i do it????
I used relationship endpoint to do it
https://api.instagram.com/v1/users/{user-id}/relationship?access_token=ACCESS-TOKEN
let newJson1 = JSON(data: NSData(contentsOfURL: NSURL(string: "https://api.instagram.com/v1/users/\(self.id)/relationship?access_token=\(self.accessToken)")!)!, options: NSJSONReadingOptions.AllowFragments, error: nil)
print(newJson1)
but none of the results found....
Do you have some advices? Thanks
#John Instagram limits the api access. For that you have to approve your app permission from the sandbox. Once the Instagram approves your permission, then you can access of the relevant data. Approving permission can be done by submitting your app to Instagram.